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?
That should be
Get-HVMachineSummary -PoolName "Accenture"|
Select-Object -Property @{N='Name';E={$_.Base.Name}},
@{N='User';E={$_.NamesData.UserName}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That should be
Get-HVMachineSummary -PoolName "Accenture"|
Select-Object -Property @{N='Name';E={$_.Base.Name}},
@{N='User';E={$_.NamesData.UserName}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
L.
how can I list all the properties, aside from experience? how do you come up with " NamesData.UserName"
Thanks Chief
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference