Last active
August 29, 2015 14:03
-
-
Save kacole2/68e74480bd458d901402 to your computer and use it in GitHub Desktop.
VMware View Active Session Count using PowerCLI
This file contains 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment