VMware : Basic ESXi commands

By | August 25, 2016

You will find below some basic and useful commands to operate a ESXi hypervisor from the command line.

Put the host in maintenance mode (or leave maintenance mode) :

esxcli --server localhost system maintenancemode set --enable <true | false>

List all VMs registered on the host :

vim-cmd vmsvc/getallvms

Verify the power state of a specific VM :

vim-cmd vmsvc/power.getstate <vmid>

Power on a specific VM :

vim-cmd vmsvc/power.on <vmid>

Backup the host configuration :

vicfg-cfgbackup --server localhost -s /tmp/ESXi-cfgbackup.txt

Restore backup configuration to the host (have to be in maintenance mode) :

vicfg-cfgbackup --server localhost -l /tmp/ESXi-cfgbackup.txt

Show the VMkernel networks on the host :

esxcli --server localhost network ip interface list

EXTRA : For any “esxcli” commands, you can run the following to run the command to a remote host (such as from vCenter/PowerCLI) :

esxcli --server <server_ip> - -username “username” - -password “password” <COMMAND>