If you replace:
Get-VM
into:
Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"}
then you will only get the vm's that are powered on.
If you replace:
Get-VM
into:
Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"}
then you will only get the vm's that are powered on.