The result of same script is displayed in two formats while calling using powershell.invoke and pipeline.invoke

StackOverflow https://stackoverflow.com/questions/20897935

Question

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?

No correct solution

OTHER TIPS

Not sure but the powershell.invoke output looks like an object-output via write-host and the pipeline.invoke looks like write-output output even though both should return a psobject. More code would be helpful

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top