Skip to content

Instantly share code, notes, and snippets.

@Psmths
Last active December 8, 2021 01:59
Show Gist options
  • Save Psmths/2cdbb5d9da02f0b8f02fde2dfd3c3fbd to your computer and use it in GitHub Desktop.
Save Psmths/2cdbb5d9da02f0b8f02fde2dfd3c3fbd to your computer and use it in GitHub Desktop.
Enumerating ESXi Hosts

Enumerating ESXi Hosts

List all guest machines

# vim-cmd vmsvc/getallvms

Example output:

Vmid   Name             File                 Guest OS       Version   Annotation
2      test   [ds-nfs-01] test/test.vmx   debian9_64Guest   vmx-19

Get host system version

# esxcli system version get

Example output:

Product: VMware ESXi
Version: 7.0.2
Build: Releasebuild-17867351
Update: 2
Patch: 0

Get fully qualified domain name

# esxcli system hostname get

Example output:

Domain Name: localdomain
Fully Qualified Domain Name: localhost.localdomain
Host Name: localhost

Get list of local accounts

# esxcli system account list

Example output:

User ID  Description
-------  -----------
root     Administrator
dcui     DCUI User
vpxuser  VMware VirtualCenter administration account

Add a user

# esxcli system account add -d "John Doe" -i jdoe -p "mypasswrd1!" -c "mypasswrd1!"

Get firewall allowlist

# esxcli network firewall ruleset list | grep true

Example output:

sshServer                       true
nfsClient                       true
dhcp                            true
dns                             true
snmp                            true
CIMHttpServer                   true
CIMHttpsServer                  true
CIMSLP                          true
vpxHeartbeats                   true
updateManager                   true
faultTolerance                  true
webAccess                       true
vMotion                         true
vSphereClient                   true
NFC                             true
HBR                             true
DHCPv6                          true
DVSSync                         true
WOL                             true
iofiltervp                      true
trusted-infrastructure-kmxa     true

Get interface addresses

# esxcli network ip interface ipv4 get

Example output:

Name  IPv4 Address  IPv4 Netmask  IPv4 Broadcast  Address Type  Gateway         DHCP DNS
----  ------------  ------------  --------------  ------------  --------------  --------
vmk0  10.200.200.4  255.255.0.0   10.200.255.255  STATIC        10.200.254.254     false

Get list of snapshots

# esxcli storage vmfs snapshot list

Get list of virtual disks

# esxcli storage vmfs extent list

Example output:

Volume Name                                 VMFS UUID                            Extent Number  Device Name          Partition
------------------------------------------  -----------------------------------  -------------  -------------------  ---------
ds1                                         61afdc58-d495675e-e09b-000c2977c092              0  mpx.vmhba1:C0:T2:L0          1
ds2                                         61afdc60-e253ccd2-f789-000c2977c092              0  mpx.vmhba1:C0:T1:L0          1
OSDATA-61ae3c7c-841485c8-5734-000c2977c092  61ae3c7c-841485c8-5734-000c2977c092              0  mpx.vmhba1:C0:T0:L0          7

Get all filesystem mounts

# esxcli storage filesystem list
Example output:

Mount Point                                        Volume Name                                 UUID                                 Mounted  Type           Size         Free
-------------------------------------------------  ------------------------------------------  -----------------------------------  -------  ------  -----------  -----------
/vmfs/volumes/4e72c69e-66184a54                    ds-nfs-01                                   4e72c69e-66184a54                       true  NFS     23583965184  19136004096
/vmfs/volumes/61afdc58-d495675e-e09b-000c2977c092  ds1                                         61afdc58-d495675e-e09b-000c2977c092     true  VMFS-6  68451041280  66941091840
/vmfs/volumes/61afdc60-e253ccd2-f789-000c2977c092  ds2                                         61afdc60-e253ccd2-f789-000c2977c092     true  VMFS-6  68451041280  66941091840
/vmfs/volumes/61ae3c7c-841485c8-5734-000c2977c092  OSDATA-61ae3c7c-841485c8-5734-000c2977c092  61ae3c7c-841485c8-5734-000c2977c092     true  VFFS    98515812352  95543099392
/vmfs/volumes/d65eff05-014fd4cf-859b-0a637b6003be  BOOTBANK1                                   d65eff05-014fd4cf-859b-0a637b6003be     true  vfat     4293591040   4085121024
/vmfs/volumes/97929ab9-a4468f4a-5ca6-720ce52ea066  BOOTBANK2                                   97929ab9-a446
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment