command lines on esxi

Register a VM

vim-cmd solo/registervm path_to_vmx_file

Unregister a VM

vim-cmd vmsvc/unregister vmid

Delete a VM

vim-cmd vmsvc/destroy vmid

Get a listing of VMs on a host

esxcli vm process list
vim-cmd vmsvc/getallvms

Determine if a VM has a snapshot

vim-cmd vmsvc/get.snapshot vmid

Take a snapshot of a VM

vim-cmd vmsvc/snapshot.create vmid snapshot_name

Remove a snapshot of a VM

vim-cmd vmsvc/snapshot.remove vmid

Get the current power state of a VM

vim-cmd vmsvc/power.getstate vmid

Get the uptime for a VM

vim-cmd vmsvc/get.summary vmid |grep uptimeSeconds

Power on a VM

vim-cmd vmsvc/power.on vmid

Shutdown a VM

vim-cmd vmsvc/power.shutdown vmid

Shutdown a VM

vim-cmd vmsvc/power.shutdown vmid

Power off a VM

esxcli vm process killw world_id
vim-cmd vmsvc/power.off vmid

Reboot a VM

vim-cmd vmsvc/power.reboot vmid

Reset a VM

vim-cmd vmsvc/power.reset vmid

Upgrade VMware Tools in a VM

vim-cmd vmsvc/tools.upgrade vmid

Display the IP address of a VM

vim-cmd vmsvc/get.guest vmid |grep -m 1 "ipAddress = \""

Display all info for all vmnics

for i in $(esxcfg-nics -l | awk '{print $1}' | tail -n +2); do esxcli network nic get -n $i; done

Show syslog host

vim-cmd hostsvc/advopt/view Syslog.Remote.Hostname | grep -i "value =" | awk -F'"' '{print $2}'

Show syslog target port

vim-cmd hostsvc/advopt/view Syslog.Remote.Port | grep "value =" | sed -e 's/^.*value = \([^ ,]*\).*$/\1/'

Show scratch location

vim-cmd hostsvc/advopt/view Syslog.Local.DatastorePath | grep -i "value =" | awk -F'"' '{print $2}'

Get task list of VM

vim-cmd vmsvc/get.tasklist <VMID>

Get info for a specified task

vim-cmd vimsvc/task_info <TaskNr>

See the number in the “vim.Task …. ” line

Get memory information

vsish -e get /memory/comprehensive
Comprehensive {
   Physical memory estimate:12454784 KB
   Given to VMKernel:12454784 KB
   Reliable memory:0 KB
   Discarded by VMKernel:1580 KB
   Mmap critical space:0 KB
   Mmap buddy overhead:3084 KB
   Kernel code region:18432 KB
   Kernel data and heap:14336 KB
   Other kernel:1421360 KB
   Non-kernel:120036 KB
   Reserved memory at low addresses:59900 KB
   Free:10875956 KB
}


Authors:
  • Jochen Schnuerle