## How to (quickly) match a moRef ID to a name in VMware vSphere

Every object within a vSphere environment is internally tracked, and referred to, by a unique identifier called moRef ID (“Managed Object Reference ID”).

Every virtual infrastructure object managed by vSphere (datacenters, clusters, hosts, datastores, VMs, vApps, vSwitches and so on) has a moRef ID.

## What is the moRef ID?

This identifier is composed of a prefix stating the object type, followed by a numerical ID. For example:

vm-613

host-22

datastore-33

It is important to note that this identifier is guaranteed to be unique only within a single vCenter instance. In this article by William Lam it is explained that an additional identifier called InstanceUUID (unique for a given vCenter) was introduced in vSphere 5.0 that, when coupled with the moRef ID, gives a truly globally unique value.

Quick note: the moRef ID is not to be confused with VMs’ UUID. This universally unique value is stored in the SMBIOS and is conceptually similar to the unique BIOS system identifier in physical systems. This value, unlike the moRef ID, can be duplicated even within the same vCenter, for example as a result of a cloning operation, or a restore from backup.

If you ever need to examine logs from VMware components/solutions or 3rd party software integrating with vSphere, you’ll notice that objects often appear with their moRef ID rather than their name attribute.

For this reason, you may need from time to time to quickly match a moRef ID to the more “friendly” object name. As usual, there are several ways to do this.

## Looking up moRef IDs using PowerCLI

PowerCLI is a really cool tool and one of the things you can do with it, is looking up moRef IDs in a fairly easy way.

Note: if you are installing PowerCLI on a Windows Server 2012 / R2 box, you’ll need to enable the .NET Framework 3.5 features (which also include .NET Framework 2.0 features), which can be non-trivial in some cases. There’s a nice how-to in this post.

Once you have PowerCLI up and running, you can connect to your vCenter instance (or single ESX/i host) using the Connect-VIServer cmdlet, and then easily obtain detailed info.

Connect-VIServer <vcenter_or_host> -User <foo\bar> -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.

The “ID” field returned by PowerCLI is actually the moRef, preceded by a slightly more “verbose” string stating the object type. For example:

VirtualMachine-vm-613

HostSystem-host-628

Datastore-datastore-642

You can get a very simple table with a one-liner, for example (for VMs):

Get-VM | ft -Property Name,ID -AutoSize

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> | ft -Property Name,ID -AutoSize

Replace Get-VM with Get-VMHost or Get-Datastore (for example) to carry out equivalent operations on other object types.

Get-VMHost -ID <*moRef> | ft -Property Name,ID -AutoSize
Get-Datastore -ID <*moRef> | ft -Property Name,ID -AutoSize

## Looking up moRef IDs using RVTools

This extremely handy freeware set of tools by Rob de Veij is a long-time favourite among the vSphere aficionados. It offers a great amount of detailed data, in an easily exportable format too.

The latest version of RVTools, v3.6, has been released in February 2014. A fellow italian virtualization professional, Francesco Bonetti, has also recently made a nice post on his blog about RVTools.

After you log in to your vCenter or host, you can get information about the various vSphere object types by clicking on the corresponding tab. You can find the moRef ID value in the result table. It is usually at the very end, look for the “Object Id” column to the far right.

The same can be done for hosts, datastores and so forth. For datastores, you can find the info under the “vMultiPath” tab and not “vDatastore“.

## Looking up moRef IDs using the vSphere MOB (Managed Object Browser)

In my experience, this valuable tool is often overlooked by vSphere admins. Its main advantage is that you don’t have to install or configure anything – it is a WebApp, all you need is a browser.

Pointing to:

https://<vCenter_server>/mob/?moid=<OBJECT_ID>

will look up the specified moRef ID and return the corresponding object with all its properties, including its name of course.

You can also browse your whole infrastructure tree simply pointing to

https://<vCenter_server>/mob/

## Looking up moRef IDs using Veeam ONE (shameless plug alert!)

As you probably already know, Veeam doesn’t only offer a backup/disaster recovery solution, but a complete virtualization management product too. It is called Veeam ONE and it also integrates with Veeam Backup & Replication.

It is extremely easy to use, yet quite powerful. But enough with the chit-chat, let’s get to it!

You can create a nice-looking report showing the objects you want in no time, complete with moRef IDs.

Just go into the “Workspace” section of Veeam ONE Reporter’s web console:

http://<veeam_one_server>:1239/Workspace

Create a “Custom Infrastructure” report in Veeam ONE Reporter’s web console and populate it with the data you need. Once you specify the “Object Type” you can add as many columns as you like, there’s also an easy real-time search function that filters columns as you type.

Once you build the report with the desired data, you can save it as a custom report and you can also set its scheduling/distribution options. You’ll find the report in the “My reports” folder if you left the default value for the report destination folder.

The report can be instantly viewed in the browser and then saved in PDF, Word or Excel format. It can also be scheduled as as an e-mail attachment or saved to a local/shared folder of your choice.

… And there you have it! Enjoy! 😉

## 5 thoughts on “How to (quickly) match a moRef ID to a name in VMware vSphere”

1. Veeresh Kumar

Hi DC,

Thanks for the post. I am new to vmware. I have a use case where I have to find the MOR id from the vm itself. The vm s a linux one and it is provided with vmware tools. Is there any way to find MOR id using vmware tools? Plese help me out.

Veeresh

1. Danilo Post author

Hi Veeresh,

obtaining the MOR / MoRef (and other info) from within the guest OS is possible, but it’s non-trivial in most cases.

You can use vmtoolsd to retrieve VM-specific info:

vmtoolsd --cmd "info-get guestinfo.[variable]"

It seems there is not much documentation around, after a quick search I found that you can read variables after you set them at the VMX level (either dynamically, or statically editing the VMX file).

Note: the visibility of vmtoolsd is limited to the “guestinfo” entity, so any variable you want to parse must be in the form guestinfo.[variable]

The only info I could retrieve without setting custom variables or editing the VMX file was the IP address:

vmtoolsd --cmd "info-get guestinfo.ip"

A solution could be using PowerCLI or other scripting tools (at the vCenter/host level) to automatically populate custom variables, such as the MOR/MoRef, Guest OS Hostname and so on.