I am re-working a colleagues PowerShell script (1000+ lines), and I have noted this odd behaviour:
[pscustomobject]$obj = @{"Colour" = "Blue"; "Car" = "Volkswagen"}
# Check the variable.
$obj
Name Value
---- -----
Car Volkswagen
Colour Blue
Using a different method:
$obj = [pscustomobject]@{"Colour" = "Blue"; "Car" = "Volkswagen"}
# Check the variable.
$obj
Colour Car
------ ---
Blue Volkswagen
The properties 'Name' and 'Value' are removed for the custom object. What is happening here?