Powershell - inconsistent output from the same code
Use a calculated property {$_.sourceaddress.IPAddress}
:
$output |
Sort-Object pscomputername, remoteaddress |
Format-Table -Property pscomputername,
{$_.sourceaddress.IPAddress},
remoteaddress, remoteport, tcptestsucceeded
You can use a hash table to add calculated properties to an object before displaying it and to specify the column headings in the table. To add a calculated property, use the Property
or GroupBy
parameter.
$output |
Sort-Object pscomputername, remoteaddress |
Format-Table -Property pscomputername,
@{Name='sourceaddress';Expression={$_.sourceaddress.IPAddress}},
remoteaddress, remoteport, tcptestsucceeded