Require Elevation and use Open File Dialog

In this commit, we require elevation which is needed to add the self-signed cert to the Personal store, and to the registry.

We also use the OpenFileDialog to select the target RDP File
This commit is contained in:
yois615 2026-04-29 11:40:47 -04:00 committed by GitHub
parent bc3b87dd76
commit 82cc90b4ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,7 @@
# ==============================================================================
#Requires -RunAsAdministrator
# ==============================================================================
# SIGN RDP CONNECTION FILES YOU CREATE ON THE MACHINE USING A SELF-SIGNED CERTIFICATE TO SUPRESS APRIL 2026 RDP SECURITY UPDATE WARNINGS WHEN OPENING REMOTE DESKTOP FILES
# This file should be run on the machine you are connecting FROM.
# https://learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/remotepc/understanding-security-warnings#:~:text=When%20an%20RDP%20file%20is,as%20the%20following%20image%20shows.
# https://msrc.microsoft.com/update-guide/vulnerability/CVE-2026-26151
# NOTE!! THIS WILL NO LONGER SHOW THE "Remote Desktop Connection security warning" FOR ANY SIGNED FILES AND ENSURES THESE FILES CAN'T BE MODIFIED AFTER SIGNING WITHOUT INVALIDATING THE SIGNATURE, WHICH WILL MAKE THE WARNING REAPPAER
@ -9,7 +11,17 @@
# ==============================================================================
# 1. Configuration
$rdpFile = "C:\Users\Desktop\RDPFILENAME.rdp"
Add-Type -AssemblyName System.Windows.Forms
$folderselection = New-Object System.Windows.Forms.OpenFileDialog -Property @{
InitialDirectory = [Environment]::GetFolderPath('Desktop')
Filter = "RDP Files (*.rdp)|*.rdp"
}
$folderselection.ShowDialog()
$rdpFile = $folderselection.Filename
$certSubjectName = "CompanyNameIT-RDP"
$certSubject = "CN=$certSubjectName"
@ -75,4 +87,4 @@ if (Test-Path $rdpFile) {
Write-Host "Success! RDP file is ready for use." -ForegroundColor Green
} else {
Write-Error "Target RDP file not found at $rdpFile"
}
}