Skip to content

Instantly share code, notes, and snippets.

@josy1024
Created October 25, 2019 06:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josy1024/e88c496645fdc168f6fc9698efb19900 to your computer and use it in GitHub Desktop.
Save josy1024/e88c496645fdc168f6fc9698efb19900 to your computer and use it in GitHub Desktop.
Decrypting Remote Desktop Connection Manager Passwords from settings file with PowerShell
# author: josef lahmer
# thanks to https://smsagent.blog/2017/01/26/decrypting-remote-desktop-connection-manager-passwords-with-powershell/
# Path to RDCMan.exe
$RDCMan = "C:\Program Files (x86)\Microsoft\Remote Desktop Connection Manager\RDCMan.exe"
# Path to RDG file
# $RDGFile = "$env:USERPROFILE\Documents\RDPConnections.rdg"
$RDGFile = "$env:LOCALAPPDATA\Microsoft\Remote Desktop Connection Manager\RDCMan.settings"
$TempLocation = "C:\temp"
Copy-Item $RDCMan "$TempLocation\RDCMan.dll"
Import-Module "$TempLocation\RDCMan.dll"
$EncryptionSettings = New-Object -TypeName RdcMan.EncryptionSettings
$XML = New-Object -TypeName XML
$XML.Load($RDGFile)
# for settings file
$logonCredentials = Select-XML -Xml $XML -XPath '//credentialsProfile'
# for rdg file
#$logonCredentials = Select-XML -Xml $XML -XPath '//logonCredentials'
$Credentials = New-Object System.Collections.Arraylist
$logonCredentials | foreach {
[void]$Credentials.Add([pscustomobject]@{
Username = $_.Node.userName
Password = $(Try{[RdcMan.Encryption]::DecryptString($_.Node.password, $EncryptionSettings)}Catch{$_.Exception.InnerException.Message})
Domain = $_.Node.domain
})
} | Sort Username
$Credentials | Sort Username
@mckenzm
Copy link

mckenzm commented Sep 28, 2022

Be good to extend this for certificates as well, not just logon credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment