vSphere esxcli cheatsheet

List all esxcli subcommands:

[root@esxi-01:~] esxcli esxcli command list
Namespace                                           Command       Description
--------------------------------------------------  ------------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ams.ahslog                                          disable       Disable CPU and Memory Usage periodic logging to AHS.
ams.ahslog                                          enable        The time interval parameter indicates how often CPU and Memory Usage will be logged to AHS.
ams.ahslog                                          show          Show the current CPU and Memory Usage periodic logging interval value in minutes. A value of 0 indicates that CPU and Memory Usage periodic logging is disabled.
ams.periodictrap                                    disable       Disable the periodic test trap.
ams.periodictrap                                    enable        The time interval parameter indicates how often the periodic test trap will be sent.
ams.periodictrap                                    show          Show the current periodic test trap interval value in seconds. A value of 0 indicates that the periodic test trap is disabled.
bootcfg                                             execute       execute bootcfg command with options parameter
bootcfg                                             help          show bootcfg help
bootcfg                                             show          show current bootcfg settings
device                                              add           Add a device to enable a software device driver.
device.alias                                        get           Display hardware location info for a device alias.
device.alias                                        list          List device aliases.
<------------------------------SNIP------------------------------>

List commands for VM operations:

[root@esxi-01:~] vim-cmd vmsvc
Commands available under vmsvc/:
acquiremksticket                 get.snapshotinfo
acquireticket                    get.spaceNeededForConsolidation
createdummyvm                    get.summary
destroy                          get.tasklist
device.connection                getallvms
device.connusbdev                gethostconstraints
device.ctlradd                   message
device.ctlrremove                power.getstate
device.disconnusbdev             power.hibernate
device.diskadd                   power.off
device.diskaddexisting           power.on
device.diskextend                power.reboot
device.diskremove                power.reset
device.getdevices                power.shutdown
device.nvdimmadd                 power.suspend
device.nvdimmremove              power.suspendResume
device.toolsSyncSet              queryftcompat
devices.createnic                reload
get.capability                   setscreenres
get.config                       snapshot.create
get.config.cpuidmask             snapshot.dumpoption
get.configoption                 snapshot.get
get.datastores                   snapshot.remove
get.disabledmethods              snapshot.removeall
get.environment                  snapshot.revert
get.filelayout                   snapshot.setoption
get.filelayoutex                 tools.cancelinstall
get.guest                        tools.install
get.guestheartbeatStatus         tools.upgrade
get.managedentitystatus          unregister
get.networks                     upgrade
get.runtime

List VM processes:

[root@esxi-01:~] esxcli vm process list
web01
   World ID: 2100981
   Process ID: 0
   VMX Cartel ID: 2100976
   UUID: 56 4d 8e 8a 42 5e 7a 63-3b cf 8e e5 8a 9c 3c 45
   Display Name: web01
   Config File: /vmfs/volumes/5903354e-f69b6ecf-7ac2-a0d3c106a2d8/web01/web01.vmx

Kill VM with specific World ID:

[root@esxi-01:~] esxcli vm process kill -w 2100981

List networks associated with VM’s:

[root@esxi-01:~] esxcli network vm list
World ID  Name                   Num Ports  Networks
--------  ---------------------  ---------  --------
 2100981  web01             1  DATTST

List ports for a given VM:

[root@esxi-01:~] esxcli network vm port list -w 2102302
   Port ID: 33554441
   vSwitch: vSwitch0
   Portgroup: DAT
   DVPort ID:
   MAC Address: 00:50:56:8b:b1:a0
   IP Address: 0.0.0.0
   Team Uplink: vmnic0
   Uplink Port ID: 33554434
   Active Filters:

List standard vSwitch:

[root@esxi-01:~] esxcli network vswitch standard list
vSwitch0
   Name: vSwitch0
   Class: cswitch
   Num Ports: 5376
   Used Ports: 9
   Configured Ports: 128
   MTU: 9000
   CDP Status: listen
   Beacon Enabled: false
   Beacon Interval: 1
   Beacon Threshold: 3
   Beacon Required By:
   Uplinks: vmnic1, vmnic0
   Portgroups: DATMGT, DCN, DAT, DATTST, vMotion, Management Network

vSwitch1
   Name: vSwitch1
   Class: cswitch
   Num Ports: 5376
   Used Ports: 7
   Configured Ports: 128
   MTU: 9000
   CDP Status: listen
   Beacon Enabled: false
   Beacon Interval: 1
   Beacon Threshold: 3
   Beacon Required By:
   Uplinks: vmnic3, vmnic2
   Portgroups: iSCSI2, iSCSI1

List ARP table:

[root@esxi-01:~] esxcli network ip  neighbor list
Neighbor       Mac Address        Vmknic    Expiry  State  Type
-------------  -----------------  ------  --------  -----  -------
172.16.1.1     a4:53:0e:b7:91:bc  vmk0    1129 sec         Unknown
192.168.100.1  00:c0:ff:18:5b:fc  vmk2     377 sec         Unknown
192.168.100.2  00:c0:ff:18:b5:76  vmk2     752 sec         Unknown
192.168.200.1  00:c0:ff:18:4f:7e  vmk3     596 sec         Unknown
192.168.200.2  00:c0:ff:18:62:ba  vmk3     483 sec         Unknown

List routing table:

[root@esxi-01:~] esxcli network ip route ipv4 list
Network        Netmask          Gateway      Interface  Source
-------------  ---------------  -----------  ---------  ------
default        0.0.0.0          172.16.1.1   vmk0       MANUAL
10.250.0.0     255.255.0.0      0.0.0.0      vmk0       MANUAL
192.168.100.0  255.255.255.0    0.0.0.0      vmk2       MANUAL
192.168.200.0  255.255.255.0    0.0.0.0      vmk3       MANUAL
192.255.254.0  255.255.255.224  0.0.0.0      vmk1       MANUAL

List network interfaces:

[root@esxi-01:~] esxcli network ip interface list
vmk0
   Name: vmk0
   MAC Address: 2c:76:8a:5d:d3:d4
   Enabled: true
   Portset: vSwitch0
   Portgroup: Management Network
   Netstack Instance: defaultTcpipStack
   VDS Name: N/A
   VDS UUID: N/A
   VDS Port: N/A
   VDS Connection: -1
   Opaque Network ID: N/A
   Opaque Network Type: N/A
   External ID: N/A
   MTU: 1500
   TSO MSS: 65535
   RXDispQueue Size: 1
   Port ID: 33554438
<------------------------------SNIP------------------------------>

List network interfaces with IP addresses:

[root@esxi-01:~] esxcli network ip interface ipv4 get
Name  IPv4 Address     IPv4 Netmask     IPv4 Broadcast   Address Type  Gateway      DHCP DNS
----  ---------------  ---------------  ---------------  ------------  -----------  --------
vmk0  172.16.1.12      255.255.0.0      10.250.255.255   STATIC        172.16.1.1      false
vmk1  192.255.254.11   255.255.255.224  192.255.254.31   STATIC        0.0.0.0         false
vmk2  192.168.100.111  255.255.255.0    192.168.100.255  STATIC        0.0.0.0         false
vmk3  192.168.200.111  255.255.255.0    192.168.200.255  STATIC        0.0.0.0         false

List VMkernel errors and their meaning when working with VM’s:

[root@esxi-01:~] vmkerrcode -l

VMK_ReturnStatus table for VMware ESX Server, Build #130756
Name                             Dec         Hex          errno equiv    Description
-------------------------------------------------------------------------------
VMK_OK                           0           0            OK            Success
VMK_FAILURE                      195887105   0xbad0001    EINVAL        Failure
VMK_WOULD_BLOCK                  195887106   0xbad0002    EAGAIN        Would block
VMK_NOT_FOUND                    195887107   0xbad0003    ENOENT        Not found
VMK_BUSY                         195887108   0xbad0004    EBUSY         Busy
VMK_EXISTS                       195887109   0xbad0005    EEXIST        Already exists
VMK_LIMIT_EXCEEDED               195887110   0xbad0006    EFBIG         Limit exceeded
VMK_BAD_PARAM                    195887111   0xbad0007    EINVAL        Bad parameter
VMK_METADATA_READ_ERROR          195887112   0xbad0008    EIO           Metadata read error
VMK_METADATA_WRITE_ERROR         195887113   0xbad0009    EIO           Metadata write error
VMK_IO_ERROR                     195887114   0xbad000a    EIO           I/O error
VMK_READ_ERROR                   195887115   0xbad000b    EIO           Read error
VMK_WRITE_ERROR                  195887116   0xbad000c    EIO           Write error
<------------------------------SNIP------------------------------>

Drop into maintenance mode:

[root@esxi-01:~]  esxcli system maintenanceMode get
Disabled
[root@esxi-01:~]  esxcli system maintenanceMode set --enable true