Files
RDPSign/app/Clearsigning.ps1
T
GCH 2225abed9d feat(RDPSign): Get-DesktopPaths OneDrive Desktop support + compressed changelogs
- Opdatér Get-DesktopPaths i alle 7 app-scripts: brug Get-ChildItem
  -Filter 'Desktop' -Depth 2 i stedet for Join-Path/Test-Path
  så OneDrive-omdirigeret Desktop også fanges
- Tilføj -Exclude 'Public','Default' for at springe systemprofiler over
- Komprimér og opdatér changelog i alle scripts med ny version
- Fjern old_app/ (arkiveret v1.0 scripts)
- Opdatér README.md og README.html
2026-06-02 08:23:16 +02:00

56 lines
2.2 KiB
PowerShell

# ============================================================
# CHANGELOG
# v1.2 - Get-DesktopPaths: Depth 2 search for OneDrive Desktop
# v1.1 - AllUsers switch + Get-DesktopPaths helper
# v1.0 - Initial
# ============================================================
param(
[switch]$AllUsers
)
function Get-DesktopPaths {
if ($AllUsers) {
Get-ChildItem "$env:SystemDrive\Users" -Directory -Exclude "Public","Default" | ForEach-Object {
Get-ChildItem $_.FullName -Directory -Filter "Desktop" -Depth 2 -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty FullName
}
} else {
[Environment]::GetFolderPath("CommonDesktopDirectory")
}
}
$certSubject = "CN=RDPSign"
# 1. Unsign RDP files
foreach ($desktopPath in (Get-DesktopPaths)) {
$rdpFiles = Get-ChildItem -Path $desktopPath -Filter "*.rdp"
foreach ($file in $rdpFiles) {
$content = Get-Content $file.FullName
$cleaned = $content | Where-Object { $_ -notmatch "^signscope:s:" -and $_ -notmatch "^signature:s:" }
$cleaned | Set-Content $file.FullName -Encoding Unicode
Write-Host "Unsigned: $($file.Name) on $desktopPath"
}
}
# 2. Remove certificate from all stores
foreach ($storeName in @("My", "Root", "TrustedPublisher")) {
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store($storeName, "LocalMachine")
$store.Open("ReadWrite")
$certs = $store.Certificates | Where-Object { $_.Subject -eq $certSubject }
foreach ($cert in $certs) {
$store.Remove($cert)
Write-Host "Removed certificate from store: $storeName"
}
$store.Close()
}
# 3. Remove thumbprint from registry
$gpoPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"
Remove-ItemProperty -Path $gpoPath -Name "TrustedCertThumbprints" -ErrorAction SilentlyContinue
Write-Host "Removed TrustedCertThumbprints"
# 4. Remove RedirectionWarningDialogVersion
$clientPath = "HKLM:\Software\Policies\Microsoft\Windows NT\Terminal Services\Client"
Remove-ItemProperty -Path $clientPath -Name "RedirectionWarningDialogVersion" -ErrorAction SilentlyContinue
Write-Host "Removed RedirectionWarningDialogVersion"