From 348b1a00bc663bdc61ffca201077c42279e5bf72 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 6 Aug 2024 00:02:07 +0200 Subject: [PATCH] Add a function for removing desktop icons --- scripts/Windows/Scripts/System.ps1 | 23 +++++++++++++++++++++ scripts/Windows/Software/Windows/Manage.ps1 | 2 ++ 2 files changed, 25 insertions(+) diff --git a/scripts/Windows/Scripts/System.ps1 b/scripts/Windows/Scripts/System.ps1 index 33b473b4..952b96c1 100644 --- a/scripts/Windows/Scripts/System.ps1 +++ b/scripts/Windows/Scripts/System.ps1 @@ -6,3 +6,26 @@ function New-TemporaryDirectory { $path = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()); New-Item -ItemType Directory $path; } + +<# + .SYNOPSIS + Removes desktop icons which apply to the specified pattern. + + .PARAMETER Pattern + The pattern to match the icons to delete. +#> +function Remove-DesktopIcon { + param( + [string] $Pattern + ) + + $path = "Desktop/$Pattern"; + + foreach ($userDir in @($(~), $env:PUBLIC, "$env:SystemDrive/Users/Default")) { + $fullName = "$userDir/$path"; + + if (Test-Path -PathType Leaf $fullName) { + Remove-Item $fullName; + } + } +} diff --git a/scripts/Windows/Software/Windows/Manage.ps1 b/scripts/Windows/Software/Windows/Manage.ps1 index a90b281a..d2866e07 100644 --- a/scripts/Windows/Software/Windows/Manage.ps1 +++ b/scripts/Windows/Software/Windows/Manage.ps1 @@ -66,6 +66,8 @@ Start-SoftwareInstaller @PSBoundParameters ` $startLayoutFile = "start.json"; Write-Host "Removing adware"; + Remove-DesktopIcon "*Microsoft Edge*"; + Edit-DefaultUserKey { param ( [RegistryKey] $Key