Listed below are commands that can be used in ESX/vSphere console. Some of them have been very useful to me but some other just for fun.
To List all the Virtual Machine System Files
[root@vsphere02 ~]# vmware-cmd -l
/vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx
/vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx
To Get the Power state of VM
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx getstate
getstate() = off
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx getstate
getstate() = on
To create a snapshot, if revertsnapshot is specified it goes to the current snapshot.
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx createsnapshot ‘SNAP01′ ‘1st’ 1 1
createsnapshot(SNAP01, 1st, 1, 1) = 1
=> If the <quiesce> flag is 1 and the virtual machine is powered on when the
snapshot is taken, VMware Tools is used to quiesce the file system in the virtual
machine. Quiescing a file system is a process of bringing the on‐disk data of a
physical or virtual computer into a state suitable for backups. This process might
include such operations as flushing dirty buffers from the operating systemʹs
in‐memory cache to disk, or other higher‐level application‐specific tasks.
=> If the <memory> flag is 1, a dump of the internal state of the virtual machine is
included in the snapshot. Memory snapshots take longer to create.
To check if a VM has a snapshot. 0 means no and 1 means yes. To remove all snapshot, instead of hassnapshot use removesnapshots
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx hassnapshot
hassnapshot() = 0
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx removesnapshots
removesnapshots() = 1
Power on a VM from command line
Seems VMware Tools needs to be running for us to use the STOP command. start()=1 means it successfully sent the start signal. You can also use SUSPEND or RESET.
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx start
start() = 1
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx getstate
getstate() = on
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx stop
vim.fault.ToolsUnavailable: Cannot complete operation because VMware Tools is not running in this virtual machine.
If the VMware Tools is not started or not working or the server is in Hung mode then you may use the HARD way to stop the server. stop(hard)=1 means it successfully sent stop signal.
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx stop hard
stop(hard) = 1
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx getid
getid() = 112
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx getheartbeat
getheartbeat() = 59
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx getheartbeat
getheartbeat() = 65
To get the uptime (Seconds) of OS on VM
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx getuptime
getuptime() = 764
To check the status of HeartBeat of VM
The command can return one of the following:
0 – VMware Tools are not installed or not running.
1 – Guest operating system is responding normally.
5 – Intermittent heartbeat. There might be a problem with the guest operating
system.
100 – No heartbeat. Guest operating system might have stopped responding.
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/FT01/FT01.vmx gettoolslastactive
gettoolslastactive() = 1
The following command will show the product details
If product is specified, the return value is one of the following:
=> gsx – VMware Server or GSX Server
=> esx – VMware ESX
=> embeddedESX – VMware ESXi
=> vpx – VMware vCenter Server
=> unknown (unknown product type)
If platform is specified, the return value is one of the following:
=> win32-x86 – x86‐based Windows system
=> linux-x86 – x86‐based Linux system
=> vmnix-x86 ‐ x86 ESX/ESXi microkernel
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx getproductinfo product
getproductinfo(product) = esx
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx getproductinfo platform
getproductinfo(platform) = vmnix-x86
The following will show the Build, MajorVersion and MinorVersion
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx getproductinfo build
getproductinfo(build) = 164009
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx getproductinfo majorversion
getproductinfo(majorversion) = 4
[root@vsphere02 ~]# vmware-cmd /vmfs/volumes/48320651-c5176d12-c595-000c29e099d5/Win2003/Win2003.vmx getproductinfo minorversion
getproductinfo(minorversion) = 0
For more commands download vsp_40_vCLI.pdf from www.vmware.com