Restarting another old thread here as the previous shows as answered and this is a bit different.
With COVID-19 our management is trying to keep a close eye on the resources consumed by teleworkers and how well it is scaling.
In the below I can get a count of all sessions that are coming in from the external connection servers. Unfortunately the NamesData Class doesn't have the SessionData.SessionState. I need to be able to pull both the SessionState and SecurityGatewayDNS at the same time.
If both:
SessionData.SessionState -eq CONNECTED
SecurityGatewayDNS -like "view.company.org"
Then I have an active, external, View session.
Anyone know how to get the connection state of the guests? This gets a count of both connected and disconnected.
Import-Module -Name VMware.VimAutomation.HorizonView
Connect-HVServer connectionserver
$query = New-Object "Vmware.Hv.QueryDefinition"
$query.queryEntityType = 'SessionLocalSummaryView'
$qSrv = New-Object "Vmware.Hv.QueryServiceService"
$rslt = $qSRv.QueryService_Query($global:DefaultHVServers[0].ExtensionData,$query)
$rslt | Select-Object -ExpandProperty Results |
Select-Object -ExpandProperty NamesData |
where-Object {$_.SecurityGatewayDNS -like "view.company.org"} |
Select-Object -Property UserName,MachineOrRDSServerName,MachineOrRDSServerDNS,SecurityGatewayAddress |
Measure-Object |
Select-Object count