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) :
1 |
esxcli --server localhost system maintenancemode set --enable <true | false> |
List all VMs registered on the host :
1 |
vim-cmd vmsvc/getallvms |
Verify the power state of a specific VM :
1 |
vim-cmd vmsvc/power.getstate <vmid> |
Power on a specific VM :
1 |
vim-cmd vmsvc/power.on <vmid> |
Backup the host configuration :
1 |
vicfg-cfgbackup --server localhost -s /tmp/ESXi-cfgbackup.txt |
Restore backup configuration to the host (have to be in maintenance mode) :
1 |
vicfg-cfgbackup --server localhost -l /tmp/ESXi-cfgbackup.txt |
Show the VMkernel networks on the host :
1 |
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) :
1 |
esxcli --server <server_ip> - -username “username” - -password “password” <COMMAND> |