This mostly worked, the end output was just what I wanted.
2 things though. Our network security alarmed on this activity with this showing up in their console:
powershell -NonInteractive -EncodedCommand cABvAHcAZQByAHMAaABlAGwAbAAuAGUAeABlACAALQBPAHUAdABwAHUAdABGAG8AcgBtAGEAdAAgAHQAZQB4AHQAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0AQwBvAG0AbQBhAG4AZAAgACcAJgAgAHsARwBlAHQALQBTAGUAcgB2AGkAYwBlACAALQBOAGEAbQBlACAAJwAnAFgAYQBnAHQAJwAnACAAfAAgAFMAZQBsAGUAYwB0ACAALQBFAH=
which decoded was something like this:powershell.exe -OutputFormat text -NonInteractive -Command '& {Get-Service -Name ''WinRm'' | Select -ExpandProperty Status}' .....
Can this work be done without the encoding part?
If I wanted to run it against a known set of server names, would this be it?
$script = @"
Get-Service -Name 'WinRm' | Select -ExpandProperty Status
"@
$report = read-host = .\server.txt| %{
Invoke-VMScript -VM $_ -ScriptText $script -ScriptType Powershell |
select @{N='VM';E={$_.VM.Name}},@{N='Status';E={$_.ScriptOutput.Trim()}}
}
$report | Export-Csv .\report.csv -NoTypeInformation -UseCulture