I cannot get the following to work with a list of vms. only one at a time
$allLines = @() # Line added
Get-VM -Name (Get-Content -Path "C:\vms.txt") |`
ForEach-Object {
If ($_.Powerstate -eq "poweredOff") {
echo $_ is powered off
}
Else {
Shutdown-VMGuest $_ -Confirm:$false -RunAsync
sleep 60
Move-VM $_ -Destination xxx.xxx.com -Confirm:$false -RunAsync
sleep 5
Get-NetworkAdapter | Set-NetworkAdapter -NetworkName dvPG-vlan245 -Confirm:$false -RunAsync
Start-VM $_ -Confirm:$false -RunAsync
}
}
any idea why I cannot run the task on all vms together?