I am trying to find a means of listing all the View sessions, not the vCenter sessions, the user sessions of all users connected to a View guest, their user ID, their hostname, and other information. I can't find anywhere in the powershell documentation where I would do this. Does anyone know where to look? This is for VMWare 6.x.
I just learned the name of our connection servers, I wasn't aware that these are separate, but then again I'm not the main VMware engineer.
Changing to:
PowerCLI C:\> $rslt = $qSRv.QueryService_Query($global:DefaultHVServers[0].ExtensionData,$query)
Gets a result:
PowerCLI C:\> $rslt
Id StartingOffset RemainingCount Results
-- -------------- -------------- -------
0 0 {VMware.Hv.SessionId, VMware.Hv.SessionId, VMware.Hv.SessionId, VMware.Hv.SessionId...
Then:
$rslt | Select -ExpandProperty Results | Select -ExpandProperty NamesData | Select-Object -Property UserName,DesktopType,DesktopName,MachineOrRDSServerDNS
Returns info.
Now if I could make it return based upon connection server...
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
Hi All,
how can we get the count of connected users into a variable i.e. $connectUsers returns 2550 sessions as opposed to listing all the sessions.
Using the above measure-object and count always returns 1000 which isnt right
Thank you this worked! Very Helpful.
I added this into a loop for every 15 Seconds it lists my users .. and i sorted MachineOrRDSServerName. Again Very Helpful!
$i =1
while ($i -le 2) {$qSRv.QueryService_Query($global:DefaultHVServers[0].ExtensionData,$query) | select -ExpandProperty Results | select -ExpandProperty NamesData | Select UserName,MachineOrRDSServerName |sort MachineOrRDSServerName | ft;
sleep 15 ;
write-output “————”
;clear-host
write-output “VDI User Sessions”
write-output “————”
Write-Host `n
}
I just added a count as well, so w/ looping the count and sessions I don't need to be in Horizon all the time.
($qSRv.QueryService_Query($global:DefaultHVServers[0].ExtensionData,$query) |select -ExpandProperty Results | select -ExpandProperty NamesData | Select UserName,MachineOrRDSServerName |sort MachineOrRDSServerName).count
Thanks!!
The limit of 1000 seems to be a resultsize issue with the query. I see that all the time with AD but don't see how to override in VMware.
More info here:
https://www.retouw.nl/powercli/get-hvmachine-only-finds-1000-desktops/
Do you know the property name to show the Session State? So we can see the state of each VM in the table as well? I tried using Session, SessionState and none of them worked.