Sunday, October 4, 2015

Looking up MoRef (Managed Object Reference) IDs in vSphere environment

Today I saw a question about VM MOID like how to get it. The answer could be pretty simple like using RVTools,
But what are the other ways, before talking about that, first understand what this MoRef ID is. Every object within a vSphere environment is internally tracked, and has a unique identifier called moRef ID. A Managed Object Reference ID also known just as MoRef ID is a unique value that is generated by the vCenter Server and is guaranteed to be unique for a given entity in a single vCenter instance.
This identifier is composed of a prefix stating the object type, followed by a numerical ID, for example:

host-25
vm-11
datastore-09   etc.

You can check the MoRef ID of a host by going to this URL:
https://vC_Server FQDN_or_IP/vod/index.html


Now we will look up the specified moRef ID using Managed Object Browser it will show you the corresponding object with all its properties, including its name of course.for other objects. Go to https://vC_Server FQDN_or_IP/mob/?moid=host-id


From here you will get the MoRef IDs of other objects and can get further detail about the by using managed object browser.

To check moRef IDs using PowerCLI, for this connect to your vCenetr or a host using using the Connect-VIServer cmdlet,
Connect-VIServer <vcenter_or_host> -User uaser_name -Password *****

After you have successfully connected, the Get-<object_type> cmdlets allow you to know which object has a particular MoRef ID in no time,
Get-VMHost | ft -Property Name, ID


The “ID” field returned by PowerCLI is actually the moRef, preceded by a slightly more “verbose” string stating the object type.
Replace Get-VMHost with  Get-VM or Get-Datastore to carry out equivalent operations on other object types

You can always search for a specific ID, just be sure to add an asterisk (*) before the moRef ID you are looking for so you don’t have to include the object type string every time.
Get-VM -ID *moRef_id | ft -Property Name,ID                                        or
Get-Datastore -ID *moRef_id | ft -Property Name,ID -AutoSize

Reference: Danilo Chiavari and William Lam's blog posts.

That's it... :)


2 comments:

  1. Many thanks for clearing my concept of MOID. So what i understood is Vcenter provides MOID to each instance like VM, Host and Datastore. now if i take scenario of master election process, if both host have same datastore connection then the higher MOID will be will be consider as master right ? So my question is how vcenter will decide that to which host need to give higher MOID?

    ReplyDelete
    Replies
    1. here you are relating two different things....vCenter assigned MOID is something that vCenter assigns to every object which is registered in vCenter inventory....while during the HA election process, the host which have max number of objects available on it becomes master...

      Delete