The following code:
$test = @( [PsCustomObject] @{ PSTypeName = 'Type'; Field1 = "a"} )
$test2 = @("x")
Write-Output $test
foreach ($x in $test2)
{
Write-Warning $x
}
gives this output:
WARNING: x
Field1
------
a
Why is the order in which things are printed different from expected - Write-Output
being first in the code.
Note that this only happens if $test
is a PsCustomObject
.