From 77e5e9e95fe3f85bcc47d8b34235be81e9921ff0 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 18 Jul 2023 20:55:12 +0200 Subject: [PATCH] Fix manipulation of write-protected array --- scripts/Windows/Config/Windows/InstallUser.ps1 | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/scripts/Windows/Config/Windows/InstallUser.ps1 b/scripts/Windows/Config/Windows/InstallUser.ps1 index f315c5e6..cad677ca 100644 --- a/scripts/Windows/Config/Windows/InstallUser.ps1 +++ b/scripts/Windows/Config/Windows/InstallUser.ps1 @@ -16,10 +16,9 @@ Write-Information "Remove ads from pinned apps"; Export-StartLayout $startLayoutFile; $startLayout = Get-Content "$startLayoutFile" | ConvertFrom-Json; -[System.Collections.Generic.List[System.Object]] $removalQueue = @(); -foreach ($pinnedItem in $startLayout.pinnedList) { - if ( +$startLayout.pinnedList = $startLayout.pinnedList | Where-Object { + return ( ($pinnedItem.desktopAppLink -like "*Microsoft Edge*") -or [System.Linq.Enumerable]::Any( @( @@ -34,13 +33,7 @@ foreach ($pinnedItem in $startLayout.pinnedList) { [System.Func[System.Object,bool]]{ param($pattern) return $pinnedItem.packageAppId -like "$pattern"; - })) { - $removalQueue += @($pinnedItem); - } -} - -foreach ($item in $removalQueue) { - $startLayout.pinnedList -= $item; + })); } $startLayout | ConvertTo-Json | Set-Content $startLayoutFile;