Add script for removing pinned icons

This commit is contained in:
Manuel Thalmann 2023-07-18 20:04:34 +02:00
parent 09ebe21397
commit 749b73c699
2 changed files with 11 additions and 0 deletions

View file

@ -28,6 +28,11 @@ class Context {
Remove-Item "$env:PUBLIC/Desktop/$pattern"; 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() { [Microsoft.Win32.RegistryKey] EnsureConfigKey() {
if (-not (Test-Path $this.ConfigRoot)) { if (-not (Test-Path $this.ConfigRoot)) {
$null = New-Item $this.ConfigRoot; $null = New-Item $this.ConfigRoot;

View file

@ -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:InformationPreference = "Continue";
$Global:ErrorActionPreference = "Inquire"; $Global:ErrorActionPreference = "Inquire";