Quantcast
Channel: VMware Communities : Document List - vSphere PowerCLI
Viewing all articles
Browse latest Browse all 379

Shutdown VM in specific Resource Pools

$
0
0

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

  }

}

}


Viewing all articles
Browse latest Browse all 379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>