VMware Cloud Community
GreenIT
Enthusiast
Enthusiast

Gracefully shutting down Virtual Infrstructure

Hello,

We have about 400 VM's (Windows and Linux) running on ESX 3.5 and ESXi 4.1 . We are movig this infrstructure so need to shutdown all the VM's.

Can I automate this process so that we do not have to individually power down each VM?

Thanks in advance!

Reply
0 Kudos
2 Replies
CRad14
Hot Shot
Hot Shot

As long as all your VMs have vmware tools installed you should just be able to do a

Get-VM | Shutdown-VMGuest

This will grab all the VM and shutdown their OS

If you wanted to test this on just a few VMs you could pick a folder and do

Get-VM -location "FolderName" | Shutdown-VMGuest

Or even just one VM

Shutdown-VMGuest -vm "VMName"           OR          Get-VM "VMName" | Shutdown-VMGuest

Hope this helps

Conrad www.vnoob.com | @vNoob | If I or anyone else is helpful to you make sure you mark their posts as such! 🙂
Shoganator
Enthusiast
Enthusiast

CRad14's post explains a way of doing this. Alan Renouf has also blogged a script on how to shutdown VI before too - it goes a step further and will also shutdown your ESXi hosts too (unless you are running your vCenter server(s) as VMs too though). Check it out here: http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/ (it goes without saying, be careful playing with cmdlets that will shutdown anything - VMs, Hosts etc)!

Finally, if you use any of the above for shutting down your VMs, if you have any which do not have VMware tools installed and do not shutdown with the above script, do something like this to get a list back of VMs still running which can then be manually powered down:

$VM = Get-VM | Where {$_.PowerState -ne "PoweredOn"}

If you would like a way of shutting down VMs with Windows guests which do not have VMware Tools installed for some reason, you could use the normal PowerShell Cmdlet Stop-Computer. This can shutdown remote computers too. Example below:

Stop-Computer -Computerame MYSERVERNAME -Force

Hope that helps!

Sean

My personal blog: http://www.shogan.co.uk .::. Twitter: shogan85 .::. if an answer has helped or solved your question, please don't forget to mark as "Answered" or "Helpful"!