Fix manipulation of write-protected array

This commit is contained in:
Manuel Thalmann 2023-07-18 20:55:12 +02:00
parent 023070b0c4
commit 77e5e9e95f

View file

@ -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;