Skip to content

Powershell – Monitor RDS Usercount

With Remote Desktop servers sometimes clogging up, I found it useful to have the user count monitored. When the limit exceeds what the RDS actually can handle, which is of course variable depending on the hardware you use, things go bad. But usually no matter how much hardware is thrown against it, it seems that 25-30 is the maximum in most cases.

So I’ve made a short and easy script that reads the numbers which can be used in your monitoring software.


$RDUsersActive = Get-RDUserSession | where {$_.SessionState -eq "STATE_ACTIVE" -or $_.SessionState -eq "STATE_CONNECTED"}
$RDUsersDisconnected = Get-RDUserSession | where {$_.SessionState -eq "STATE_DISCONNECTED"}

$TotalCount = $RDUsersActive.Count + $RDUsersDisconnected.Count
$TotalConnected = $RDUsersActive.Count
$TotalDisconnected = $RDUsersDisconnected.Count

Published inPowerShellRemote Desktop ServicesServer 2012Server 2016Server 2019

Be First to Comment

Leave a Reply

Your email address will not be published.