How to Get VM UUID from VM OS w/o Using vCenter REST API

Mindwatering Incorporated

Author: Tripp W Black

Created: 08/05 at 05:16 PM

 

Category:
VMWare
VM Configuration

Task:
Find the VM UUID w/o using the vCenter/vSphere REST API.


Glossary Reminder and Dangers:
The short id returned by the vSphere API is the MoRefID.
e.g. vm-123

The instanceUuid is new in the API 4.0, and it replaces using the BIOS uuid which could be changed by certain actions. It's the long id of hexadecimal letters and numbers.
e.g. 123a1bc4-a123-b12c-de12-a123456bc123

If your environment has only one vCenter, then either ID is unique.
If your environment has multiple vCenters, then you need either id, plus the vCenter's own instanceUuid.
If you esxi host is/was unmanaged, and VMs were created, those MoRefIDs are only unique to that ESXi host.

The MoRefID will also be reset/replaced, if the VM is
- unregistered from vSphere or the ESXi host, when not managed, and then given a new one, when re-added to the environment.
- vMotion'd/Storage vMotion'd
- DR restored
- Backup restored

The VM's vmx file has:
uuid.bios - machine UUID, this may no longer match the vSphere InstanceUuid if any of the above events have occurred.
uuid.location - actual datastore path

If you are prompted for Moved vs. Copied, and you select Move, the uuid.location is updated with the new path/datastore path in the vmx file.
If you are prompted for Moved vs. Copied, and you select Copy, the uuid.location and the uuid.bios are changed, along with the ethernet MAC address in the vmx file.



With Those caveats . . .
Solution Maybe:
$ sudo /usr/sbin/dmidecode | grep UUID
< see output >






previous page