I am calling following script to display the local user accounts in a machine :
$adsi = [ADSI]'WinNT://localhost';
$adsi.Children | where {$_.SchemaClassName -eq 'user'} |Select-Object @{n='UserName';e={$_.Name}};
When the above script is executed using powershell.invoke, the result is
@{UserName=account17}
When the same script is executed using pipeline.invoke, the result is :
UserName
--------
account17
Why is there a difference in the output for the same script when invoked using powershell and pipeline?