Compare commits
No commits in common. "main" and "release" have entirely different histories.
2 changed files with 14 additions and 24 deletions
|
|
@ -2,5 +2,11 @@
|
||||||
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 -Command "Start-Process PowerShell -ArgumentList '-ExecutionPolicy Bypass -File ""%~dp0RDPSign.ps1""' -Verb RunAs"
|
powershell.exe -executionpolicy bypass -file %drivepath%\RDPSign.ps1
|
||||||
30
RDPSign.ps1
30
RDPSign.ps1
|
|
@ -23,21 +23,14 @@ 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. 2026 |" -ForegroundColor Blue
|
Write-Host "|Copyright ACO Services Inc. 2021 |" -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. Get existing .rdp file.
|
# 1. Configuration
|
||||||
$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"
|
||||||
|
|
@ -59,17 +52,10 @@ if ([IO.Path]::GetExtension($rdpFile) -ne ".rdp") {
|
||||||
exit 3
|
exit 3
|
||||||
}
|
}
|
||||||
|
|
||||||
# 2. Set the certificate name.
|
$certSubjectName = Read-Host "Please type in your desired certificate subject name (e.g. 'CompanyNameIT-RDP')"
|
||||||
$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
|
||||||
|
|
||||||
|
|
@ -123,17 +109,15 @@ if ($existingCert) {
|
||||||
Write-Host "New certificate created and trusted." -ForegroundColor Green
|
Write-Host "New certificate created and trusted." -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
# 4. Sign the RDP File
|
# 3. 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" -ForegroundColor Red
|
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.ReadKey(“NoEcho,IncludeKeyDown”) | OUT-NULL
|
||||||
$HOST.UI.RawUI.Flushinputbuffer()
|
$HOST.UI.RawUI.Flushinputbuffer()
|
||||||
Loading…
Add table
Reference in a new issue