VMWare View, how to count active sessions

by luca
0 comment

Today I needed to track the number of active sessions of a given virtual desktop pool in my VMWare View infrastructure.

VMWare offers some cmdlets to Powershell integration; you can find them on the server where the Connection Server is installed:

You can include those cmdlets in your scripts with the command:

add-PSSnapin "VMware.View.Broker"

To get remote sessions, use Get-RemoteSession cmdlet, with the pool name as a parameter:

Get-RemoteSession -pool_id MyPool

Filter the retrieved objects based on their state (CONNECTED) and count the result:

|Where-Object{$_.state -eq "CONNECTED"}).Count

Finally save the value, with date and time.

Here’s the complete script:

add-PSSnapin "VMware.View.Broker"
(Get-Date).ToShortDateString() + " " + (Get-Date).ToShortTimeString() + " - " + ((Get-RemoteSession -pool_id MyPool)|Where-Object{$_.state -eq "CONNECTED"}).Count | out-file -FilePath "MyLog.txt" -Append

and the log file:

Related Posts

Leave a Comment

fourteen − 4 =