button-print-blu20 VMware - Useful ESXi 5 CLI Commands

You can directly access command line in ESXi 5.x either through the console (so called ESXi Shell) or using SSH with something like PUTTY.  First enable it through vSphere Client (Configuration -> Security Profile -> Services -> ESXi shell / SSH -> Options -> Start) or console menu (F2 -> login as user with root privileges -> Troubleshooting Options -> Enable ESXi Shell / Enable SSH).

Restart all services on the Host
/sbin/services.sh restart
Show config file of vCenter vpxa agent
cat /etc/vmware/vpxa/vpxa.cfg


Put Host in to Maintenance Mode
vim-cmd hostsvc/maintenance_mode_enter

Virtual machine operations

vim-cmd vmsvc/getallvms – list all VMs registered on the host, better viewed in a wide PUTTY window!
* in the following commands replace <vmid> with virtual machine ID (Vmid) obtained by running the previous command, see screen shot below

vim-cmd vmsvc/power.getstate <vmid> – show power state of a VM
vim-cmd vmsvc/power.shutdown  <vmid>  – shutdown a VM gracefully (using VMwareTools installed on the guest)
vim-cmd vmsvc/power.on <vmid> – power on a VM (if powered off)
vim-cmd vmsvc/get.summary  <vmid>  – get summary information for a VM

vim-cmd vmsvc/power.reboot <vmid> – reboot a VM (pull the power and restart it)
vim-cmd vmsvc/power.off <vmid>  – power off a VM (pull the power)
vim-cmd vmsvc/power.reset  <vmid>  – reset a VM (unknown definition)
button-print-blu20 VMware - Useful ESXi 5 CLI Commands  CLI-GetAllVMs-300x93 VMware - Useful ESXi 5 CLI Commands

..and with extreme caution…

vim-vmd solo/registervm <path to VM’s .vmx file> – register VM on a host
vim-cmd vmsvc/unregister  <vmid>  – unregister a VM from a host

 

One thought on “VMware – Useful ESXi 5 CLI Commands

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress spam blocked by CleanTalk.