From 9534e8f7d24582b08ee1920cfb34b071023d45e0 Mon Sep 17 00:00:00 2001 From: GCH Date: Tue, 2 Jun 2026 07:53:48 +0200 Subject: [PATCH] =?UTF-8?q?feat(RDPSign):=20opdat=C3=A9r=20Get-DesktopPath?= =?UTF-8?q?s=20til=20OneDrive=20Desktop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Erstat Join-Path/Test-Path med Get-ChildItem -Filter "Desktop" -Depth 2 så OneDrive-omdirigeret Desktop også fanges - Tilføj -Exclude "Public","Default" for at springe systemprofiler over - Anvendt i app/Install.ps1, Detect.ps1, Uninstall.ps1, SignOnly.ps1, SignOnly_detect.ps1, Clearsigning.ps1, sandbox.ps1 --- app/Clearsigning.ps1 | 7 +++---- app/Detect.ps1 | 6 +++--- app/Install.ps1 | 8 +++----- app/SignOnly.ps1 | 7 +++---- app/SignOnly_detect.ps1 | 7 +++---- app/Uninstall.ps1 | 7 +++---- app/sandbox.ps1 | 7 +++---- 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/app/Clearsigning.ps1 b/app/Clearsigning.ps1 index 1b57cf0..36727f6 100644 --- a/app/Clearsigning.ps1 +++ b/app/Clearsigning.ps1 @@ -13,15 +13,14 @@ param( function Get-DesktopPaths { if ($AllUsers) { - Get-ChildItem "$env:SystemDrive\Users" -Directory | ForEach-Object { - $path = Join-Path $_.FullName "Desktop" - if (Test-Path $path) { $path } + 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 diff --git a/app/Detect.ps1 b/app/Detect.ps1 index 6a01ea6..de0da96 100644 --- a/app/Detect.ps1 +++ b/app/Detect.ps1 @@ -39,9 +39,9 @@ function Write-Log { function Get-DesktopPaths { if ($AllUsers) { - Get-ChildItem "$env:SystemDrive\Users" -Directory | ForEach-Object { - $path = Join-Path $_.FullName "Desktop" - if (Test-Path $path) { $path } + 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") diff --git a/app/Install.ps1 b/app/Install.ps1 index 4abeee9..71644cc 100644 --- a/app/Install.ps1 +++ b/app/Install.ps1 @@ -34,16 +34,14 @@ function Write-Log { function Get-DesktopPaths { if ($AllUsers) { - # Return desktop path for each user profile found - Get-ChildItem "$env:SystemDrive\Users" -Directory | ForEach-Object { - $path = Join-Path $_.FullName "Desktop" - if (Test-Path $path) { $path } + 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") } } - try { $desktopPaths = Get-DesktopPaths Write-Log "Running in mode: $(if ($AllUsers) { 'All Users' } else { 'Public Desktop' })" diff --git a/app/SignOnly.ps1 b/app/SignOnly.ps1 index 3d48797..30840a3 100644 --- a/app/SignOnly.ps1 +++ b/app/SignOnly.ps1 @@ -34,15 +34,14 @@ function Write-Log { function Get-DesktopPaths { if ($AllUsers) { - Get-ChildItem "$env:SystemDrive\Users" -Directory | ForEach-Object { - $path = Join-Path $_.FullName "Desktop" - if (Test-Path $path) { $path } + 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") } } - try { $certSubjectName = "RDPSign" $certSubject = "CN=$certSubjectName" diff --git a/app/SignOnly_detect.ps1 b/app/SignOnly_detect.ps1 index 71d2cc6..8eb0323 100644 --- a/app/SignOnly_detect.ps1 +++ b/app/SignOnly_detect.ps1 @@ -13,15 +13,14 @@ param( function Get-DesktopPaths { if ($AllUsers) { - Get-ChildItem "$env:SystemDrive\Users" -Directory | ForEach-Object { - $path = Join-Path $_.FullName "Desktop" - if (Test-Path $path) { $path } + 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" # Check certificate exists in all three stores diff --git a/app/Uninstall.ps1 b/app/Uninstall.ps1 index 6776a24..650d156 100644 --- a/app/Uninstall.ps1 +++ b/app/Uninstall.ps1 @@ -27,15 +27,14 @@ function Write-Log { function Get-DesktopPaths { if ($AllUsers) { - Get-ChildItem "$env:SystemDrive\Users" -Directory | ForEach-Object { - $path = Join-Path $_.FullName "Desktop" - if (Test-Path $path) { $path } + 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") } } - try { $desktopPaths = Get-DesktopPaths Write-Log "Running in mode: $(if ($AllUsers) { 'All Users' } else { 'Public Desktop' })" diff --git a/app/sandbox.ps1 b/app/sandbox.ps1 index 5244f00..20d38b1 100644 --- a/app/sandbox.ps1 +++ b/app/sandbox.ps1 @@ -36,15 +36,14 @@ function Write-Log { function Get-DesktopPaths { if ($AllUsers) { - Get-ChildItem "$env:SystemDrive\Users" -Directory | ForEach-Object { - $path = Join-Path $_.FullName "Desktop" - if (Test-Path $path) { $path } + 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") } } - # ============================================================ # INSTALL # ============================================================