PowerCLI

 View Only
  • 1.  Using Get-View to find Uid of an Object

    Posted Sep 27, 2013 06:59 PM

    I am looking for the Uid property of an object, in my example a ESXi host, but I need it from Get-View and not Get-VMhost.

    For example if I run Get-VMhost | Select Uid it returns: /VIServer=userA@vCenterName:443/VMHost=HostSystem-host-001/

    Is there any way to get this same return using Get-View -ViewObject HostSystem -Property xxxxxx?

    In the long run what I need to do is be able to pull the vCenter name that this ESXi host is connected to. In the past I have used the Client property to pull this information, however it appears that property will be going away soon. I will be connected to multiple vCenters at once, so simply dumping $global:DefaultVIServer is not an option. Any suggestions would be helpful. We have an extremely large environment so I need the quickest possible way to pull this information.

    Thanks in advance!



  • 2.  RE: Using Get-View to find Uid of an Object

    Posted Sep 27, 2013 09:25 PM

    If you look at the help for Uid property, you'll see that it is a unique identifier for PowerCLI objects.

    So I'm afraid there is no serverside object counterpart property.

    But you can construct the Uid yourself from the parts that are available, and with the help of the $uidUtil variable.

    Get-View -ViewType HostSystem |
    Select Name,@{N="Uid";E={$uidUtil.Append($global:DefaultVIServer.Id,"VMHost",$_.MoRef)}}