Tuesday, September 18, 2007

vimsh : handy Vmware ESX Command line tool

Hi,

Recently learned/discovered a handy command line tool on ESX :

vimsh

If you just run vimsh and press enter, you enter a sort of separate command line interface

You can do various things with this CLI here some examples :

vmsvc/getallvms :
gives you a list of all registered virtual machines

vmsvc/poweron, vmsvc/poweroff, vmsvc/powerstate :
change/query powerstate of virtual machines

vmsvc/removedisk
remove a virtual disk while your virtual machine is online
for example vmsvc/removedisk 64 0 4 N removes SCSI device 0:4 from virtual machine with vmID 64, the N leaves the virtual disk file intact.

/hostsvc/vmotion/vnic_set portgroup3
enables vmotion on portgroup3, handy to integrate in post-setup configuration scripts

and much much more ...
You can find a detailed white paper about vimsh at the great site http://www.xtravirt.com/index.php?option=com_remository&Itemid=75&func=fileinfo&id=4

 

For scripting purposes you can use this command in non-interactive mode, for example :

vimsh -ne vmsvc/getallvms > /root/registeredvms.txt