Today was a happy day. One of my co-workers asked me if I can help him with a little PowerShell. I never say ‘no’ to this.
So what’s the story? He needed to get some performance counters from a bunch of remote servers. Those are in different domain so Get-Counter won’t work - no Credential parameter. He wrapped it up in Invoke-Command, but then got some errors. Basicaly this was the ‘problematic’ part:
He wanted to generate counters on the endpoint, get the results through Invoke-Command and export them locally on his machine to further investigate. This is what he got:
The issue here is, that data returned through Invoke-Command is deserialized, which is not the original
So, I came up with a little bit different idea:
This is (nearly) the code we’ve end up: