RDS Troubleshooting

Lately, I stumbled upon a PowerShell script, written by a Microsoft employee.

From time to time, the only information you get in RDS / RDP troubleshooting situations is a simple error number. The script mentioned (and shown below) allows the “translation” of the error number to an error message which may reveal some more information to you.

Microsoft released an RDS diagnostic tool – to find the tool’s description and download link point your browser to this URL: https://cloudblogs.microsoft.com/enterprisemobility/2013/11/04/remote-desktop-services-diagnostic-tool/.

This PowerShell script translates an RDS error code to a human-readable message:

# Script converts an disconnectReason RDS error code to the according error message
# Found on techgenix.com
Param(
   [parameter(Position=0,Mandatory=$true,HelpMessage="Enter the disconnect reason code in decimal from client side rds trace")]
   [string]$disconnectReason
)
# If it looks like a hex then try and convert to dec
if([regex]::IsMatch($disconnectReason, "[a-fA-FxX]")) {
   $disconnectReason =[Convert]::ToInt32($disconnectReason,16)
}
Write-Host "checking error code:$disconnectReason"
$mstsc = New-Object -ComObject MSTscAx.MsTscAx
write-host "description: $($mstsc.GetErrorDescription($disconnectReason,0))"


Next, Microsoft released an RDS diagnostic tool – to find the tool’s description and download link point your browser to this URL: https://cloudblogs.microsoft.com/enterprisemobility/2013/11/04/remote-desktop-services-diagnostic-tool/.


As I get new troubleshooting tools and tips, I’m gonna add them – Happy RDS troubleshooting!

Leave a Reply

Your email address will not be published. Required fields are marked *