VMware Cloud Community
H0merrJ
Contributor
Contributor

Server reboot sequencing

Looking for a code snippet to do the following

Shutdown Server #1

reboot server #2

Wait for server to come back fully

Power Up server #1

I know it is simplistic, trying to get my feet wet with PowerCLI

Thanks

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

Do you have VMware Tools installed on those VMs?


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

Reply
0 Kudos
H0merrJ
Contributor
Contributor

Yes they are installed.

Reply
0 Kudos
LucD
Leadership
Leadership

Try something like this

$srv1 = 'SRV1'

$srv2 = 'SRV2'

$vm1 = Get-VM -Name $srv1 | Shutdown-VMGuest -Confirm:$false

while($vm1.PowerState -ne 'PoweredOff'){

    sleep 5

    $vm1 = Get-VM -Name $srv1

}

$vm2 = Get-VM -Name $srv2 | Restart-VMGuest -Confirm:$false

Wait-Tools -VM $vm2

Start-VM -VM $vm1 -Confirm:$false


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

Reply
0 Kudos
H0merrJ
Contributor
Contributor

This is great. Thanks so much, I should be able to build on this.

Ian

Reply
0 Kudos