The root cause is that your lines
$a
and
$b
generate uncaptured output in the top-level script context and so result in an implicit call to Out-Default
to display the output on the console.
This is then passing the whole output from both lines into a single call to Format-Table
which has a quirk that it waits for 300ms for more data to arrive before it decides which columns to display. It looks like in that 300ms only the data from $a
is received, so it's locking the columns down to Name
and Group
. When the output from $b
is received it doesn't automatically add the GroupMembership
column.
@Santiago Squarzon's answer works around this by aligning the property names in $a
and $b
so the columns determined by Format-Table
are consistent across all of the output.
Another option is to explicitly pipe the individual variables into Format-Table
like this:
$a | format-table
...
$b | format-table
which will render two separate tables with their own columns calculated based on input to each separate call to format-table
, and will result in this on the console:
Name Group
---- -----
D2\\[email protected] {ADMINS, WebService}
D2\\[email protected] WebService
D2\\[email protected] WebService
D2\\[email protected] ADMINS
D2\\[email protected] WebService
Name GroupMembership
---- ---------------
D2\\[email protected] {ADMINS, WebService}
D2\\[email protected] WebService
D2\\[email protected] WebService
D2\\[email protected] WebService
See these links for more gory technical details: