Split output Select-Object


I’m trying to split a column output in two separate columns. The output i’m currently getting is:

$uDevices.data | Select-Object name,model,type,mac,last_uplink,ip | format-table
name model type mac last_uplink ip
AP_HAL_01 U7PG2 uap 80:2a:a8:56:0d:5e @{uplink_mac=44:d9:e7:05:5a:d3; uplink_remote_port=5}

The output i would like is:

name model type mac uplink_mac uplink_port ip
AP_HAL_01 U7PG2 uap 80:2a:a8:56:0d:5e 44:d9:e7:05:5a:d3 5

Hoping someone can help me with this.




How did you create this data contained in $uDevices.data ?

Hello Olaf,

The data is coming from an API connection.



Hmmm … that was not the answer I hoped for. :wink: :smiley: So I’m not able to reproduce a similar data structure. So we have to try / guess …

… try this:

$uDevices.data | 
    Select-Object -Property name, model, type, mac, 
        @{Name= 'uplink_mac'; Expression = {$_.last_uplink.uplink_mac}},
        @{Name = 'uplink_remote_port'; Expression = { $_.last_uplink.uplink_remote_port } },
        ip |
            Format-Table -AutoSize

That was it, its working.

Thank you so much Olaf!