Add a function for removing desktop icons

This commit is contained in:
Manuel Thalmann 2024-08-06 00:02:07 +02:00
parent 6268eab1e5
commit 348b1a00bc
2 changed files with 25 additions and 0 deletions

View file

@ -6,3 +6,26 @@ function New-TemporaryDirectory {
$path = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()); $path = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName());
New-Item -ItemType Directory $path; 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;
}
}
}

View file

@ -66,6 +66,8 @@ Start-SoftwareInstaller @PSBoundParameters `
$startLayoutFile = "start.json"; $startLayoutFile = "start.json";
Write-Host "Removing adware"; Write-Host "Removing adware";
Remove-DesktopIcon "*Microsoft Edge*";
Edit-DefaultUserKey { Edit-DefaultUserKey {
param ( param (
[RegistryKey] $Key [RegistryKey] $Key