VMware Cloud Community
jfierberg
Contributor
Contributor
Jump to solution

Power off All VMs

How do I use powershell to power off all of my vms and then the hosts?

Reply
0 Kudos
1 Solution

Accepted Solutions
halr9000
Commander
Commander
Jump to solution

This one is a piece of pie. Smiley Happy

Get-VM | Stop-VM

As for the hosts, that requires going to the VI SDK a little bit.

get-vmhost | % { (get-view $_.ID).ShutdownHost_Task($true) }

Hal Rottenberg

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast ()

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000

View solution in original post

Reply
0 Kudos
1 Reply
halr9000
Commander
Commander
Jump to solution

This one is a piece of pie. Smiley Happy

Get-VM | Stop-VM

As for the hosts, that requires going to the VI SDK a little bit.

get-vmhost | % { (get-view $_.ID).ShutdownHost_Task($true) }

Hal Rottenberg

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast ()

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Reply
0 Kudos