Automation

 View Only
  • 1.  VDI pool name and user list

    Posted Sep 30, 2022 11:18 PM

    hi gurus

    I am trying to get the name of the VM and the users for each machine.-> when I do this:

    "get-hvmachinesummary -PoolName "pool" I get the list of machines , user,DNS , state and all

    but when I do this:

    "get-hvmachinesummary -PoolName "Accenture"| select -ExpandProperty Base | select Name, User"

    I get the name of the VM but instead of the user name I get "VMware.Hv.UserOrGroupId"

     

    what am I doing wrong?



  • 2.  RE: VDI pool name and user list
    Best Answer

    Posted Oct 01, 2022 02:56 AM

    That should be

    Get-HVMachineSummary -PoolName "Accenture"| 
    Select-Object -Property @{N='Name';E={$_.Base.Name}},
      @{N='User';E={$_.NamesData.UserName}}


  • 3.  RE: VDI pool name and user list

    Posted Oct 01, 2022 04:01 PM

    L.

     

    how can I list all the properties, aside from experience? how do you come up with " NamesData.UserName" 

     

    Thanks Chief

     



  • 4.  RE: VDI pool name and user list
    Best Answer

    Posted Oct 01, 2022 04:50 PM

    You can do a Get-Member, but since this only lists the properties on the 1st level, you have to do the same for nested properties.

    $sumary = Get-HVMachineSummary -PoolName "Accenture"
    $summary | Get-Member
    $summary.Base | Get-Member
    $summary.NamesData | Get-Member
    


    A more precise method is to look up the info in the Horizon View API reference.
    In this case, you would need to look at the MachineNamesView object.
    But to know at which object to look you will need to "read" the code in the VMware.HV.Helper module.