VMware Cloud Community
michelvaillanco
Enthusiast
Enthusiast

Help with a script that check VM is on and if it is off it will turn it on

Hi,

I need help to add to my script the option that will check if my VM machine is on and if it is off it will turn it on.

Regards,

Michel

Tags (1)
0 Kudos
3 Replies
schepp
Leadership
Leadership

Hi,

if ($VM.PowerState -eq "PoweredOff") { $VM | Start-VM }

0 Kudos
LucD
Leadership
Leadership

You can also do that without the If.

Get-VM MyVM | Start-VM -ErrorAction SilentlyContinue


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

michelvaillanco
Enthusiast
Enthusiast

Thank you.

It works great.

Michel

0 Kudos