For Emergency case Shutdown all Running VM’s

In Emergency case (Power Lost, Backup Power Won’t Start, UPS battery gone bad) it’s fine that you have a script that will shutdown every running VM

######################################################################
# Shutdown All VM’s at Once Emergency case
######################################################################>
CLS
# write-host “Shutdown All VM’s at Once Emergency case”
$viserver = Read-Host ‘What is the name of the Virtual Center Server?’

$choice = “”
while ($choice -notmatch “[y|n]”){
     $choice = read-host “ARE YOU SURE ALL VM’s WILL SHUTDOWN? (Y/N)”
     }

if ($choice -eq “y”){
     Connect-VIServer $viserver
     $vmservers=Get-VM | Where-Object {$_.powerstate -eq ‘PoweredOn’}
     $vmservers | Shutdown-VMGuest -Confirm:$false
     }

Translate »