Stage 1 shutdown for UPS, the vm’s we don’t care about

Stage 1, shutdown down vm’s we don’t care about
add-pssnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
#stage 1, shutdown or stop vm’s not on this list
$vmsilike = "dc1","vcenter","VPNstuff","quickbooks","dc2","files","wordpress-win","exchange2010","sharepoint","sql"
$vmson = (get-vm | where {$_.powerstate -eq "PoweredOn"})
$dievms = ($vmson -like $vmsilike)
foreach ($vmso in $vmson){if ($vmsilike -notcontains $vmso.Name){
# debug Write-Host $ "shut this bitch down"}}
$fvm = Get-VM $vmso
$toolver = (get-vm $fvm |% {get-View $} | select @{Name="toolsver"; expression={$}})
if ($toolver.toolsver -gt 10000){$fvm | Stop-VM -Confirm:$false}
if ($toolver.toolsver -le 10000){$fvm | Shutdown-VMGuest -Confirm:$false}

Leave a Reply

Your email address will not be published.