Resolve Desktop path dynamically for current user

Uses Windows Known Folder API so the script works on any workstation without modifying user paths.
This commit is contained in:
cwrentmore 2026-04-16 11:46:28 -04:00 committed by GitHub
parent bc3b87dd76
commit 8e75aeba7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,11 @@
# ==============================================================================
# 1. Configuration
$rdpFile = "C:\Users\Desktop\RDPFILENAME.rdp"
# Resolve the current signed in user's Desktop path
$desktopPath = [Environment]::GetFolderPath('Desktop')
$rdpFile = Join-Path $desktopPath 'Azure\asgc-data.rdp'
$certSubjectName = "CompanyNameIT-RDP"
$certSubject = "CN=$certSubjectName"
@ -75,4 +79,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"
}
}