Learning the MoRef way of identifying objects

A MoRef is a unique identifier in the vSphere platform for every individual object. Even two objects of the same type and the same name have different MoRef identifiers. Because vSphere builds relationships based on MoRefs, you can easily rename objects, such as virtual machines or resource pools, without affecting memberships and associations.

While this recipe might seem like a bit of a tangent, it is a necessary one before moving on to building VM and Host Groups for VM to Host affinity rules. These rules do not have native PowerCLI cmdlets to manage them; therefore, you need to use object views and methods to create these configurations and those require MoRefs.

You have encountered MoRefs in other ...

Get PowerCLI Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.