PowerShell Listing different arrays -
i have 2 different arrays , when list them in script, columns of 2nd one, not appear. if list them individually, list correctly.
for example, when listing in script, output:
name ipaddress numofconnections ---- --------- ---------------- srv1 12.2.2.2 0 srv2 11.1.1.1 0 vserver1 vserver2
if list each array separately, out:
array1
name ipaddress numofconnections ---- --------- ---------------- srv1 12.2.2.2 0 srv2 11.1.1.1 0
array2
name curstate ---- -------- vserver1 vserver2 down
i suppose powershell takes first object in array , displays properties of it. if object in list has more properties, won't show them. however, iterate on items , select columns:
$array1, $array2 | foreach { $_ | select name, ipaddress, curstate }
output:
name ipaddress curstate ---- --------- -------- srv1 12.2.2.2 srv2 12.1.1.1 vserver1 vserver2 down
Comments
Post a Comment