Hi @all,
I have to messure the VMware Horizon Pool Usage for our customer over time.
Do you have some tipps for me how i can do this?
For the customer it is ok when it is like this format:
Day Pool Users
2020-06-16 | PoolA | 20 Users Active |
2020-06-16 | PoolB | 30 Users Active |
2020-06-15 | PoolA | 15 USers Active |
2020-06-15 | PoolB | 10 Users Active |
...
I know that there is vRealize which can do this with ease but is there a API where i can messure this from console / per script?
Would be nice if some could help me
Best regards
Chris
At my current customer I run a script every hour using a scheduled task which provides me information about the usage of pools and applications. I create dashboards in Power BI with this data.
In your use case you could try something like this:
## Connect to Horizon Administrator
$Connect-HVServer -Server "Your HV Server"
## Date / Time / File
$Date = Get-Date -Format dd-MM-yyyy
$Time = Get-Date -Format HH:mm
$filecsv = "Horizon_sessions_.csv"
## Query all Horizon Sessions
$ViewAPI = $global:DefaultHVServers[0].ExtensionData
$query_service = New-Object "Vmware.Hv.QueryServiceService"
$query = New-Object "Vmware.Hv.QueryDefinition"
$query.queryEntityType = 'SessionLocalSummaryView'
$Sessions = $query_service.QueryService_Query($ViewAPI,$query)
## Get all the sessions of Pool A and Pool B
$DesktopPool_A = $Sessions.Results.Namesdata | ? {$_.DesktopName -like "PoolA"}
$DesktopPool_B = $Sessions.Results.Namesdata | ? {$_.DesktopName -like "PoolB"}
## Create custom object
$Obj = New-Object -TypeName psobject
$Obj | Add-Member -MemberType NoteProperty -Name Date -Value $Date
$Obj | Add-Member -MemberType NoteProperty -Name Time -Value $Time
$Obj | Add-Member -MemberType NoteProperty -Name "PoolA" -Value $DesktopPool_A.count
$Obj | Add-Member -MemberType NoteProperty -Name "PoolB" -Value $DesktopPool_B.count
## Export object to CSV
$obj | Export-Csv -Path "C:\PowerShell\Output\$filecsv" -Append -NoTypeInformation
## Disconnect HV Server
Disconnect-HVServer -Server $HVHost -Confirm:$false
Hi Roderick,
first of all BIG THX for your script. This helps me a lot
I am not very familiar with the Horizon API coding (in general with Powershell -.-)
But now i have another question. Is there a chance to get the connected and disconnected Sessions too?
I think this is only another variable to check but i didn´t find the variable in the API Reference on
View API - VMware API Explorer - VMware {code}
Would be nice if some could help me with this
Best Regards
Chris
This would give you the number of connected and disconnected sessions.
$Connectedsessions = $Sessions.Results.Sessiondata | ? {$_.sessionstate -like "connected"}
$Connectedsessions.count
$Disconnectedsessions = $Sessions.Results.Sessiondata | ? {$_.sessionstate -like "disconnected"}
$Disconnectedsessions.count