Install SSL certificate on Windows RDP

1. Certificate thumbprint. Certificate must be installed in personal store at the computer level.

2. Run PowerShell script:

$PATH = (Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices)
Set-WmiInstance -Path $PATH -argument @{SSLCertificateSHA1Hash="thumbprint"}

 

PowerShell: convert password to secure string for RDP connection file

encrypt:

("Password!" | ConvertTo-SecureString -AsPlainText -Force) | ConvertFrom-SecureString

decrypt:

$s = ConvertTo-SecureString "encoded string"
$pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($s)
$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto($pointer)
$password