An updated version of this article can be found here: https://vmwarebits.com/moid
When accessing vCenter through the vSphere (Web) Client you will find all objects in the inventory by name, such as VM-01, ESXi-01, Datastore-01. These objects also have an internal identifier that is being used by software when logging information about these objects and you might also need those identifiers when using commands. Especially when using NSX many commands that you can execute from the NSX Manager Central CLI require the use of the identifiers. But also when working with the vSphere API or other API's such as the one for NSX the identifiers are needed to specify which object to work with.
In this article I will explore several options to find these identifiers for objects. The name for these identifiers is MOID or Managed Object IDentifier. They are in the format vm-123, host-456 et cetera.
Using the vSphere Web Client and vSphere Client
If you need to find the identifier for a single object then one of the simplest methods is to look at the address bar of your browser when accessing that object in the vSphere Web Client. In the next two examples you can see in the address bar that virtual machine DC01 has an MOID of vm-380 and Cluster01 an MOID of domain-c261.
This also works with the vSphere Client, in the next example you can see that host ESXi02 has an MOID of host-423.
Using PowerCLI
The previous method works for individual objects but it might be not efficient if you need to access this information for larger numbers of objects. In that case using PowerCLI is more practical. In the next example you can see that using command Get-VMHost | format-table name,id shows the names and identifiers for all hosts in the vCenter Inventory of the connected vCenter server.
Likewise you can use the same command structure to find virtual machines, datastores et cetera and their MOIDs:
Get-VM | format-table name,id
Get-Datastore | format-table name,id
Using vRealize Orchestrator
If you work with vRealize Orchestrator then that tool also allows you to browse through the vCenter Inventory and find what the MOID is for objects in your environment.
Using NSX Manager Central CLI
With many NSX related commands you also have to specify the ID of objects in your parameters. This is for example the case when accessing clusters or hosts. From the NSX Manager Central CLI you can use the command show cluster all which will show all clusters and then show cluster cluster-id to show the hosts for that cluster.
Likewise you can use the command show edge all to show all edge appliances and distributed logical routers.
Using the Managed Object Browser (MOB)
The last tool and the most extensive one is the Managed Object Browser that is available on each vCenter Server. Add /mob to the vCenter's address in a browser to access the tool and login with a registered vCenter User Account (or administrator@vsphere.local).
The url would look something like this: https://vcenter.domain.local/mob
After logging in click the content-link and then find the datacenters-group on the next page. From there explore the vCenter Inventory to find all objects with all their properties and also MOID's.