Invoke-Command with Try/Catch and adding to an external array

Haha that makes error collection a little easier…! That’s exactly what I was after. Thanks for that.

It seems it didn’t like having the Select-Object properties on separate lines. When I use just the one line the output is as expected:

$results | Select-Object PSComputerName,@{n="IIS";e={[bool]($_.services | Where-Object name -eq "W3SVC")}},@{n="PSVers";e={$_.PSVersion.PSVersion.Major}} | Format-Table -AutoSize

I’m sure there’s a reason but the main thing is that I think this does everything I need now but am sure I’ll be back if it doesn’t :wink:

Thanks for bearing with me guys. Much appreciated as always.

That looks correct for $results. In PowerShell everything is an object. What is displayed on the screen is just a representation of the object. If you use the property dereference operator, you can access the individual properties. i.e. $results.pscomputername or $results.services. The pipe at the end of the I sent should give you usable output to the screen.

$results |
    Sort-Object PSComputerName
        Select-Object PSComputerName,
                      @{n="IIS";e={[bool]($_.services | Where-Object name -eq "W3SVC")}},
                      @{n="PSVers";e={$_.PSVersion.PSVersion.Major}} |
            Format-Table -AutoSize