This is curiosity, I'm not stuck, just wondering... I've never seen this behaviour before and couldn't find the reason...
The code I'm executing works fine but I don't understand why the order of my columns doesn't match the order I'm adding them to my $record
...
So I create these :
$result = @()
$record = @{
"Server" = ""
"Primary DNS" = ""
"Secundary DNS" = ""
"DHCP Enabled" = ""
}
Later I add my values :
$record."Server" = $server
$record."Primary DNS" = $DNS1
$record."Secundary DNS" = $DNS2
$record."DHCP Enabled" = $NetAdapter.DHCPEnabled
$objRecord = New-Object psobject -Property $record
$result += $objRecord
But then the output of $result
gives me a table where the columns go "Primary DNS", "DHCP Enabled", "Server", "Secundary DNS".
It's not random... if I don't specify an order myself with Select-Object
, the above order is always the one I get.
Thanks in advance for the education (^^,)