VMware Cloud Community
ITMAB
Contributor
Contributor
Jump to solution

Start a VM only if other VM is powered off

Hi,

I'm looking for a way to start one specific VM only if another specific VM is powered off.
I've tried to create a simple script for this but it didn't work.

To me it should be something like getting the power state of VM1, if that is powered off, then it should start VM2

Is this possible?

regards.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Do you mean something like this ?

if((Get-VM -Name vm1).PowerState -eq "PoweredOn" -and (Get-VM -Name vm2).PowerState -eq "PoweredOff"){
  Get-VM vm2 | Start-VM -Confirm:$false
}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Do you mean something like this ?

if((Get-VM -Name vm1).PowerState -eq "PoweredOn" -and (Get-VM -Name vm2).PowerState -eq "PoweredOff"){
  Get-VM vm2 | Start-VM -Confirm:$false
}


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

0 Kudos
ITMAB
Contributor
Contributor
Jump to solution

Tested it and it worked by changing it a little bit.

Thanks!

0 Kudos