Quantcast
Channel: VMware Communities: Message List - vSphere Hypervisor
Viewing all articles
Browse latest Browse all 3837

Re: How to stop all VM quickly ?

$
0
0

Hi,

 

You can use the following few lines to shut down the guest operating systems gracefully as long as VMware Tools is installed. Open PowerCLI and connect to your VMware vCenter server by typing “Connect-VIServer vCenterServerName”.

 

To shutdown all VM guest managed by vCenter you can type the following 3 lines:

 

$vmservers=Get-VM | Where-Object {$_.powerstate -eq ‘PoweredOn’}

 

$vmservers | select Name | export-csv c:\MyScripts\servers.csv -NoTypeInformation

 

$vmservers| Shutdown-VMGuest

 

The script above will do 3 things. The first line will get all VMs that are currently powered on. The second line will log all the powered on VMs in line 1 and log them to a csv file servers.csv located in c:\MyScripts. The reason I log these machine names to a csv file is so when it’s time to turn the machines back on, I don’t inadvertently turn on any VMs that were turned off for whatever reason before I began the shutdown. The third line will shutdown the Vmware guests. The third line will ask you for confirmation before doing anything. If you don’t want to be asked for confirmation, you can simply add “-Confirm:$false” as shown below:

 

$vmservers | Shutdown-VMGuest -Confirm:$false





Viewing all articles
Browse latest Browse all 3837

Trending Articles



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