Compare commits

..

2 commits

2 changed files with 24 additions and 14 deletions

View file

@ -2,11 +2,5 @@
rem Developed by Tanner Van Teeffelen rem Developed by Tanner Van Teeffelen
rem Copyright ACO Services Inc. 2026 rem Copyright ACO Services Inc. 2026
rem Sets path equal to the location of the running script.
SET drivepath=%~dp0
rem Removes extra slash at the end of the drive path.
%drivepath:~0,-1%
rem Runs installer with the ExecutionPolicy set to bypass. rem Runs installer with the ExecutionPolicy set to bypass.
powershell.exe -executionpolicy bypass -file %drivepath%\RDPSign.ps1 powershell.exe -Command "Start-Process PowerShell -ArgumentList '-ExecutionPolicy Bypass -File ""%~dp0RDPSign.ps1""' -Verb RunAs"

View file

@ -23,14 +23,21 @@ if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent
Write-Host "-------------------------------------------" -ForegroundColor Blue Write-Host "-------------------------------------------" -ForegroundColor Blue
Write-Host "|Developed by Tanner Van Teeffelen |" -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 "|Based on MIT-licensed work by IanVanLier |" -ForegroundColor Blue
Write-Host "-------------------------------------------`n" -ForegroundColor Blue Write-Host "-------------------------------------------`n" -ForegroundColor Blue
# 1. Configuration # 1. Get existing .rdp file.
$rdpFile $rdpFile
$certSubjectName $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 = New-Object System.Windows.Forms.OpenFileDialog
$FileBrowser.Filter = "RDP Files (*.rdp)|*.rdp|All Files (*.*)|*.*" $FileBrowser.Filter = "RDP Files (*.rdp)|*.rdp|All Files (*.*)|*.*"
$FileBrowser.DefaultExt = "rdp" $FileBrowser.DefaultExt = "rdp"
@ -52,10 +59,17 @@ if ([IO.Path]::GetExtension($rdpFile) -ne ".rdp") {
exit 3 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" $certSubject = "CN=$certSubjectName"
# 2. Check for existing certificate
# 3. Check for existing certificate
Write-Host "Searching for existing certificate: $certSubjectName..." -ForegroundColor Cyan Write-Host "Searching for existing certificate: $certSubjectName..." -ForegroundColor Cyan
$existingCert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -eq $certSubject } | Select-Object -First 1 $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 Write-Host "New certificate created and trusted." -ForegroundColor Green
} }
# 3. Sign the RDP File # 4. Sign the RDP File
if (Test-Path $rdpFile) { if (Test-Path $rdpFile) {
Write-Host "Signing RDP file: $rdpFile" -ForegroundColor Cyan Write-Host "Signing RDP file: $rdpFile" -ForegroundColor Cyan
# Signing with /sha256 to match modern security standards # Signing with /sha256 to match modern security standards
rdpsign.exe /sha256 $thumbprint "$rdpFile" 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 { } else {
Write-Error "Target RDP file not found at $rdpFile" Write-Error "Target RDP file not found at $rdpFile" -ForegroundColor Red
} }
Write-Host "Press any key to exit." -ForegroundColor Green
$HOST.UI.RawUI.ReadKey(NoEcho,IncludeKeyDown) | OUT-NULL $HOST.UI.RawUI.ReadKey(NoEcho,IncludeKeyDown) | OUT-NULL
$HOST.UI.RawUI.Flushinputbuffer() $HOST.UI.RawUI.Flushinputbuffer()