Quantcast
Channel: VMware Communities : Popular Discussions - VI: VMware ESX® 3.0
Viewing all articles
Browse latest Browse all 60069

Script to Shutdown and startup of virtual machines

$
0
0

I need a script to shutdown and startup virtual machines from the ESX 3.5 console. Please also include how to run the script and also I have a few examples but not sure which is the best route to take see beloW: These were all taken from various sites of the internet and I am not sure what to do with either of them any help is greatly appreciated

 

(option 1)

Here is a bash script to power off all active VMs on a host.

#!/bin/bash

  • IFS='*

  • '*

  • for vm in `vmware-cmd -l`*

  • do*

  • name=`vmware-cmd "$vm" getconfig displayname -q`*

  • state=`vmware-cmd "$vm" getstate -q`*

  • if "$state" == "on" *

  • then*

  • echo "Trying to power off $name...."*

  • output=`vmware-cmd "$vm" stop trysoft`*

  • if $? -eq 0 ; then*

  • echo "$name was powered off successfully."*

  • fi*

  • fi*

  • done*

 

(option 2)

VMLIST=`vmware-cmd -l`

for config in $ do vmware-cmd $ stop trysoft

done

vimsh -n -e /hostsvc/maintenance_mode_enter

shutdown -h now

 

 

(option 3)

root@esxhost root--# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx stop trysoft


Viewing all articles
Browse latest Browse all 60069

Trending Articles



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