PeterRaschLager
Enthusiast
Enthusiast

Ahhh!

Got it! Each VM in the list has trailing spaces galore.

I trimmed the text file and this works:

$VMFile = "C:\Users\blahblahblah\Documents\VM.txt"

$VM = Get-Content $VMFile

foreach ($singlevm in $VM){Get-VM -Name $singlevm | where-object {$_.PowerState -eq "poweredON" }}

/Peter

Reply
0 Kudos