I suspect the Start-VM doesn't hang but that the cmdlet waits for the VM to be started, the Start-VM cmdlet runs by default in sync mode. In other words, it waits till the guest is started.
If you prefer not to wait you can do
Get-VM | where {$_.Note -match "HA"} | Start-VM -Confirm:$false -RunAsync
But beware that this will create a startup storm of VMs which can put a heavy load on your ESX(i) servers.
You can combine all this as follows
Get-Cluster $clustername | Get-VM | where {$_.Note -match "HA"} | Start-VM -Confirm:$false -RunAsync
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try this
Get-VM | where {$_.Notes -match "HA"} | Start-VM -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you,
That works just great, but unfortunately only for one WM. After that, script hangs
I am trying to perform following:
$vms = get-vm -Location (get-cluster $clustername)
To get all VMs in cluster,
and then
ForEach ($vm in $vms){$vm | where {$_.Notes -match "HA"} | Start-VM -RunAsync}But still, only one WM powers on. How can I perform this check on every machine in the cluster?
Sorry for such newbie question
I suspect the Start-VM doesn't hang but that the cmdlet waits for the VM to be started, the Start-VM cmdlet runs by default in sync mode. In other words, it waits till the guest is started.
If you prefer not to wait you can do
Get-VM | where {$_.Note -match "HA"} | Start-VM -Confirm:$false -RunAsync
But beware that this will create a startup storm of VMs which can put a heavy load on your ESX(i) servers.
You can combine all this as follows
Get-Cluster $clustername | Get-VM | where {$_.Note -match "HA"} | Start-VM -Confirm:$false -RunAsync
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for such quick response and help.
It works like a charm