VMware vSphere ESXi Commands for everyday use

In this post, I tried listing down all commands that I use everyday for ESXi Troubleshooting. I have categorized the commands for easy accessibility.

I find these commands are very useful when the ESXi host disconnected from vCenter and when not able to connect to vSphere Client.

[toggle type=”first” title=”Virtual Machine Operations”]

To get All registered VMs on the Host:
vim-cmd vmsvc/getallvms


~ # vim-cmd vmsvc/getallvms
Vmid Name     File                                  Guest OS Version       Annotation
1    DeskTop  [datastore1 (3)] DeskTop/DeskTop.vmx  windows8_64Guest       vmx-08
2    Domain   [datastore1 (3)] Domain/Domain.vmx    windows7Server64Guest  vmx-08
3    VCD55    [datastore1 (3)] VCD55/VCD55.vmx      centos64Guest          vmx-08
Power ON a VM:
vim-cmd vmsvc/power.on <VMID> 


~ # vim-cmd vmsvc/power.on 3
Powering on VM:
Power OFF a VM:
vim-cmd vmsvc/power.off <VMID> 


~ # vim-cmd vmsvc/power.off 3
Powering off VM:
 Gracefully shutdown a VM’s Guest OS:
vim-cmd vmsvc/power.shutdown <VMID> 


~ # vim-cmd vmsvc/power.shutdown 3
~ #
Register a VM
vim-cmd solo/registervm <vmxpath> 


~ # vim-cmd solo/registervm "/vmfs/volumes/datastore1 (3)/VCD55/VCD55.vmx"

UnRegister a VM:
vim-cmd vmsvc/unregister <VMID> 


~ # vim-cmd vmsvc/unregister 4
~ #



[toggle title=”Host Operations”]

Enter Host into Maintenance mode:
 vim-cmd hostsvc/maintenance_mode_enter  


Exit Host into Maintenance mode:

 vim-cmd hostsvc/maintenance_mode_exit  



[toggle title=”Storage”]


Storage Commands



To get All disks attached to ESXi host.
 esxcfg-scsidevs -l 


 esxcli core storage device list 

Sample Output.

 Display Name: HP Serial Attached SCSI Disk (naa.600508b1001c0f0e831036c264b4203e)
 Has Settable Display Name: true
 Size: 429215
 Device Type: Direct-Access
 Multipath Plugin: NMP
 Devfs Path: /vmfs/devices/disks/naa.600508b1001c0f0e831036c264b4203e
 Vendor: HP
 Revision: 3.54
 SCSI Level: 5
 Is Pseudo: false
 Status: degraded
 Is RDM Capable: true
 Is Local: false
 Is Removable: false
 Is SSD: false
 Is Offline: false
 Is Perennially Reserved: false
 Queue Full Sample Size: 0
 Queue Full Threshold: 0
 Thin Provisioning Status: unknown
 Attached Filters:
 VAAI Status: unknown
 Other UIDs: vml.0200010000600508b1001c0f0e831036c264b4203e4c4f47494341
 Is Local SAS Device: false
 Is Boot USB Device: false
 No of outstanding IOs with competing worlds: 32


 To get All disks attached to ESXi host(Compact List)
~ # esxcfg-scsidevs -c
Device UID Device Type Console Device Size Multipath PluginDisplay Name
naa.600508b1001c0f0e831036c264b4203e Direct-Access /vmfs/devices/disks/naa.600508b1001c0f0e831036c264b4203e 429215MB NMP HP Serial Attached SCSI Disk (naa.600508b1001c0f0e831036c264b4203e)
LUN to Datastore Mapping
~ # esxcfg-scsidevs -m
naa.600508b1001c0f0e831036c264b4203e:3 /vmfs/devices/disks/naa.600508b1001c0f0e831036c264b4203e:3 5131890d-0c77f39a-0382-e4115b9b7270 0 datastore1 (3)

LUN Paths:


~ # esxcfg-mpath -L
 vmhba0:C0:T0:L1 state:active naa.600508b1001c0f0e831036c264b4203e vmhba0 0 0 1 NMP active san sas.5001438027641890 sas.1438027641890

 ~ # esxcfg-mpath -m
 vmhba0:C0:T0:L1 vmhba0 sas.5001438027641890 sas.1438027641890 naa.600508b1001c0f0e831036c264b4203e

 ~ # esxcfg-mpath -b
 naa.600508b1001c0f0e831036c264b4203e : HP Serial Attached SCSI Disk (naa.600508b1001c0f0e831036c264b4203e)
 vmhba0:C0:T0:L1 LUN:1 state:active sas Adapter: 5001438027641890 Target: 1438027641890


HBA Commands

To List all HBAs available on the ESXi Host.
~ # esxcfg-scsidevs -a
vmhba0 hpsa link-n/a sas.5001438027641890 (0:3:0.0) Hewlett-Packard Company Smart Array P220i
vmhba1 qlnativefc link-up fc.50060b0000c26205:50060b0000c26204 (0:5:0.0) QLogic Corp ISP2532-based 8Gb Fibre Channel to PCI Express HBA
vmhba2 qlnativefc link-n/a fc.50060b0000c26207:50060b0000c26206 (0:5:0.1) QLogic Corp ISP2532-based 8Gb Fibre Channel to PCI Express HBA
vmhba32 iscsi_vmk online iscsi.vmhba32 iSCSI Software Adapter
HBA and LUN Mapping.
~ # esxcfg-scsidevs -A
vmhba0 naa.600508b1001c0f0e831036c264b4203e
To Rescan a HBA
esxcfg-rescan <HBANAME>


~ # esxcfg-rescan vmhba32
~ #

iSCSI Commands

Discovery Stats for a iSCSI adapter

~ # vmkiscsi-tool -D <HBANAME>


~ # vmkiscsi-tool -D vmhba32
=========Discovery Properties for Adapter vmhba32=========
 iSnsDiscoverySettable : 0
 iSnsDiscoveryEnabled : 0
 iSnsDiscoveryMethod : 0
 iSnsHost.ipAddress : ::
 staticDiscoverySettable : 0
 staticDiscoveryEnabled : 1
 sendTargetsDiscoverySettable : 0
 sendTargetsDiscoveryEnabled : 1
 slpDiscoverySettable : 0
 No Discovery Addresses Found
 No Static Discovery Targets Found
~ # vmkiscsi-tool -E <HBANME>


 ~ # vmkiscsi-tool -E vmhba32
 No active targets.
~ # vmkiscsi-tool -I HBANAME


~ # vmkiscsi-tool -I vmhba32
iSCSI Node Name: iqn.1998-01.com.vmware:is-tse-h44-56726a3c

MTU Value
~ # vmkiscsi-tool -M vmhba32


 ~ # vmkiscsi-tool -M vmhba32
 MTU Size : Not Valid


NFS Commands

To list all the mounted NFS datastores.
~ # esxcli storage nfs list


~ # esxcfg-nas -l


Add a NFS Datastore
~ # esxcli storage nfs add -H NFS_IP|NFS_HOSTNAME -s Share_mount_point_on_the_NFS -vDatastoreName


~ # esxcfg-nas -a -o NFS_IP -s Share_mount_point_on_the_NFSDatastoreName
Delete a NFS Datastore
 esxcli storage nfs remove -v NFS_Datastore_Name


esxcfg-nas -d NFS_Datastore_Name




[toggle title=”Networking”]Still Working on [/toggle]

[toggle title=”vSphere Replication”]

vim-cmd hbrsvc/



[toggle title=”Advanced & Misc “]Working on[/toggle]


3 thoughts on “VMware vSphere ESXi Commands for everyday use

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s