I'm just throwing a quickie out there...
I originally wanted to create a small ruby or python script that collected the Active Number of View Sessions currently running for a small project we are running internally. Come to find out, there isn't an API available for VMware View (TBD documentation for Horizon 6) so I had to rely on Powershell to do this for me.
I'm sure there are PS gurus out there that will tell me they can condense this down to a single line, but that's not how my brain works.
Download ViewActiveSessionCount.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add the VMware View powershell snapin | |
Add-PSsnapin VMware.View.Broker | |
#Set the connection broker to check. This isn't used since the commands are run locally | |
$ConnectionServer = "localhost" | |
#For loggin create a timestamp | |
$TimeStamp = Get-Date -format yyyy-MM-dd-H-mm | |
#grab an array of remote sessions | |
$ActiveConnections = Get-RemoteSession -State CONNECTED | |
#set initial count to 0 | |
$i = 0 | |
#do some counting | |
if ($ActiveConnections -eq $NULL){ | |
Echo "there are $i active connections" | |
} | |
else{ | |
foreach ($ActiveConnection in $ActiveConnections){ | |
$i++ | |
} | |
Echo "there are $i active connections" | |
} | |
#Add it to a logfile | |
$row = $TimeStamp + "," + $i + " Active Sessions" | |
$row | Out-File -FilePath "c:\check-active-sessions.log" -Append |