What is MO Id(Master Object Id)? and how can we check this and what is its use?
Thanks,
Prashant
Hello, Prashant-
A MOID (Managed Object ID) is something by which managed objects in vSphere can be identified. It makes up the "value" portion of the object's "MORef" -- its Managed Object Reference (at the API documentation pages).
Using PowerCLI, you can check an object's MOID or MORef by getting the "MoRef" property of that object. For example, to get all VMs' MOIDs (and MORefs), you could use:
## using Get-VM
Get-VM | select name,@{n="MOID"; e={$_.ExtensionData.MoRef.Value}}
## or, faster, using Get-View
Get-View -ViewType VirtualMachine -Property Name | select name,@{n="MOID"; e={$_.MoRef.Value}}
These would output something like:
Name MOID ---- ---- testVM0 vm-417 testVM1 vm-418 anotherVM vm-419 ...
Probably more useful is the MORef, as it can be used to retrieve .NET View objects. For example, say you have one vSwitch in your environment named, "myVSwitch0", but did not recall on which host it resided. You can find that out by getting the virtual switch object (Get-VirtualSwitch), checking the switch's "VMHostId" property, and then using Get-View to get the .NET View object for the given host. Like:
PS C:\> Get-VirtualSwitch -Name myVSwitch0 Name NumPorts Num Ports Mtu ---- -------- ---------- --- myVSwitch0 128 126 1500 PS C:\> (Get-VirtualSwitch -Name myVSwitch0).VMHostId HostSystem-host-403 PS C:\> (Get-View (Get-VirtualSwitch -Name myVSwitch0).VMHostId).Name myHost02
The first two commands are just for illustration, the last is the one that gets the VMHost name. Just a small example of MOID/MORef usage
Hello, Prashant-
A MOID (Managed Object ID) is something by which managed objects in vSphere can be identified. It makes up the "value" portion of the object's "MORef" -- its Managed Object Reference (at the API documentation pages).
Using PowerCLI, you can check an object's MOID or MORef by getting the "MoRef" property of that object. For example, to get all VMs' MOIDs (and MORefs), you could use:
## using Get-VM
Get-VM | select name,@{n="MOID"; e={$_.ExtensionData.MoRef.Value}}
## or, faster, using Get-View
Get-View -ViewType VirtualMachine -Property Name | select name,@{n="MOID"; e={$_.MoRef.Value}}
These would output something like:
Name MOID ---- ---- testVM0 vm-417 testVM1 vm-418 anotherVM vm-419 ...
Probably more useful is the MORef, as it can be used to retrieve .NET View objects. For example, say you have one vSwitch in your environment named, "myVSwitch0", but did not recall on which host it resided. You can find that out by getting the virtual switch object (Get-VirtualSwitch), checking the switch's "VMHostId" property, and then using Get-View to get the .NET View object for the given host. Like:
PS C:\> Get-VirtualSwitch -Name myVSwitch0 Name NumPorts Num Ports Mtu ---- -------- ---------- --- myVSwitch0 128 126 1500 PS C:\> (Get-VirtualSwitch -Name myVSwitch0).VMHostId HostSystem-host-403 PS C:\> (Get-View (Get-VirtualSwitch -Name myVSwitch0).VMHostId).Name myHost02
The first two commands are just for illustration, the last is the one that gets the VMHost name. Just a small example of MOID/MORef usage
A MOID (Managed Object ID) is something by which managed objects in vSphere can be identified.
Could you please elaborate the above in just interview point of view., the one you explained is in a very high level. I want to know for why it is used.
Thanks,
Prashant