Well i have a list of vm and i need to check if they are PowerdOn how i can do that fast?

You can use the get-vm cmdlet but its really slow. Not sure? Let’s make a test !

This script will do the job

$List = Get-Content "C:\Vmware\ServerList.txt" 

foreach($vm in $List)
{
$Result = Get-VM -Name $vm
Write-Host $vm " " `t $Result.PowerState
}

But it’s take around 1 minute and 41 seconds…

So i really need something faster!

$List = Get-Content "C:\ServerList.txt" 

$Result = Get-VM | where { $_.PowerState -eq "PoweredOn" }

foreach($vm in $List)
{
if($Result -match $vm)
{Write-Host $vm -NoNewline
write-host `t " Up" -ForegroundColor Green
}

}

As you can see below this script is much faster! Only 7 seconds!