Is there a way to directly gather the vmware port-id using commandline?

I'm trying to make monitoring switchports easy through esxcli but in order to get port statistics I require the portid of a VM which seems to be quite an involved operation using vMA (Virtual Machine Assistant)

Example below, I just want to easily be able to get portid by doing something like:

esxcli network portid (VMNAME) 
But I cannot find anything similar to that.

esxcli network port stats get
Error: Missing required parameter -p|--portid

Usage: esxcli network port stats get [cmd options]

  get                   Packet statistics for a given port.

Cmd options:
  -p|--portid=    Port ID for the port to get statistics. (required)
  • What edition and licensing tier of VMware are you using? – ewwhite May 15 '14 at 15:47
  • @ewwhite VMware ESXi 5.1u1 – rainereality May 15 '14 at 18:18
  • Licensing? Are you using Essentials? Essentials Plus? Enterprise Plus? – ewwhite May 15 '14 at 18:19
  • @ewwhite sorry, i'm using "standard" forgot that detail :P – rainereality May 15 '14 at 19:26

Have a look at the following link, I believe that is the command you are looking for.



I have tested the following on ESXi 6.7u2. It's possible to obtain the Port ID via the shell. First obtain the World ID for your VM:

esxcli network vm list


World ID  Name     Num Ports  Networks
--------  -------  ---------  ----------
2102511  some_vm           1  some_net


esxcli network vm port list -w 2102511

Which gives you the Port ID.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.