From 409851f563e7fb888a7bd6b2c8a4e8e671cea96f Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 18 Jul 2023 20:04:34 +0200 Subject: [PATCH] Add script for removing pinned icons --- scripts/Windows/Scripts/Context.ps1 | 5 +++++ scripts/Windows/Scripts/Prerequisites.ps1 | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index 9700bae0..21f59ade 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -28,6 +28,11 @@ class Context { Remove-Item "$env:PUBLIC/Desktop/$pattern"; } + [void] RemoveTaskbarItem($pattern) { + Import-Module -UseWindowsPowerShell PinnedItem; + Get-PinnedItem -Type TaskBar | Where-Object { $_.Name -like "$pattern" } | Remove-PinnedItem; + } + [Microsoft.Win32.RegistryKey] EnsureConfigKey() { if (-not (Test-Path $this.ConfigRoot)) { $null = New-Item $this.ConfigRoot; diff --git a/scripts/Windows/Scripts/Prerequisites.ps1 b/scripts/Windows/Scripts/Prerequisites.ps1 index d82b032a..c7047894 100644 --- a/scripts/Windows/Scripts/Prerequisites.ps1 +++ b/scripts/Windows/Scripts/Prerequisites.ps1 @@ -7,5 +7,11 @@ foreach ($module in @("PSWindowsUpdate", "KnownFolders")) } } +foreach ($nativeModule in @("PinnedItem")) { + if (-not (powershell -c Get-Module -ListAvailable $nativeModule)) { + powershell -c Install-Module -AcceptLicense -Force "$nativeModule"; + } +} + $Global:InformationPreference = "Continue"; $Global:ErrorActionPreference = "Inquire";