We have a very small VMware server population right now as we are just getting started. Consequentially keeping the non-production systems offline after hours to ensure HA resource availability is crucial for us. This script shuts off all VMs NOT in our "production" and "Infrastructure" resource pools.
$serv = Connect-VIServer -Server VC01
$pools = Get-ResourcePool -Server $serv | where-object { ($_.Name -ne "Production") -and ($_.Name -ne "Resources") -and ($_.Name -ne "Infrastructure") }
foreach ($pool in $pools ) {
$vms = Get-VM -Location $pool | where-object {$_.PowerState -eq "PoweredOn"}
foreach ($vm in $vms) {
if ( $vm -ne $null ) {
Shutdown-VMGuest -VM $vm
}
}
}