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 # ============================================================