Fix manipulation of write-protected array
This commit is contained in:
parent
023070b0c4
commit
77e5e9e95f
1 changed files with 3 additions and 10 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue