diff --git a/RDPSign.ps1 b/RDPSign.ps1 index 2a057d0..ced5997 100644 --- a/RDPSign.ps1 +++ b/RDPSign.ps1 @@ -23,14 +23,21 @@ if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent Write-Host "-------------------------------------------" -ForegroundColor Blue Write-Host "|Developed by Tanner Van Teeffelen |" -ForegroundColor Blue -Write-Host "|Copyright ACO Services Inc. 2021 |" -ForegroundColor Blue +Write-Host "|Copyright ACO Services Inc. 2026 |" -ForegroundColor Blue Write-Host "|Based on MIT-licensed work by IanVanLier |" -ForegroundColor Blue Write-Host "-------------------------------------------`n" -ForegroundColor Blue -# 1. Configuration +# 1. Get existing .rdp file. $rdpFile $certSubjectName +Write-Host "Before proceeding, please ensure that the .RDP file you select has the permissions you want" -ForegroundColor Green +Write-Host "This includes redirected printers, drives, and clipboard." -Foreground Green +Write-Host "If you make a change to the .RDP file, please run this program again after making your changes.`n" -ForegroundColor Red +Write-Host "Press any key to continue.`n" -ForegroundColor Green +$HOST.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”) | OUT-NULL +$HOST.UI.RawUI.Flushinputbuffer() + $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog $FileBrowser.Filter = "RDP Files (*.rdp)|*.rdp|All Files (*.*)|*.*" $FileBrowser.DefaultExt = "rdp" @@ -52,10 +59,17 @@ if ([IO.Path]::GetExtension($rdpFile) -ne ".rdp") { exit 3 } -$certSubjectName = Read-Host "Please type in your desired certificate subject name (e.g. 'CompanyNameIT-RDP')" +# 2. Set the certificate name. +$certSubjectName = Read-Host "Please type in your desired certificate subject name. Leave blank to use hostname" + +if ([string]::IsNullOrWhiteSpace($certSubjectName)) { + $certSubjectName = $env:COMPUTERNAME +} + $certSubject = "CN=$certSubjectName" -# 2. Check for existing certificate + +# 3. Check for existing certificate Write-Host "Searching for existing certificate: $certSubjectName..." -ForegroundColor Cyan $existingCert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -eq $certSubject } | Select-Object -First 1 @@ -109,15 +123,17 @@ if ($existingCert) { Write-Host "New certificate created and trusted." -ForegroundColor Green } -# 3. Sign the RDP File +# 4. Sign the RDP File if (Test-Path $rdpFile) { Write-Host "Signing RDP file: $rdpFile" -ForegroundColor Cyan # Signing with /sha256 to match modern security standards rdpsign.exe /sha256 $thumbprint "$rdpFile" - Write-Host "Success! RDP file is ready for use." -ForegroundColor Green + Write-Host "Success! RDP file is ready for use" -ForegroundColor Green } else { Write-Error "Target RDP file not found at $rdpFile" } +Write-Host "Press any key to exit." -ForegroundColor Green + $HOST.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”) | OUT-NULL $HOST.UI.RawUI.Flushinputbuffer() \ No newline at end of file