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;
|
Export-StartLayout $startLayoutFile;
|
||||||
|
|
||||||
$startLayout = Get-Content "$startLayoutFile" | ConvertFrom-Json;
|
$startLayout = Get-Content "$startLayoutFile" | ConvertFrom-Json;
|
||||||
[System.Collections.Generic.List[System.Object]] $removalQueue = @();
|
|
||||||
|
|
||||||
foreach ($pinnedItem in $startLayout.pinnedList) {
|
$startLayout.pinnedList = $startLayout.pinnedList | Where-Object {
|
||||||
if (
|
return (
|
||||||
($pinnedItem.desktopAppLink -like "*Microsoft Edge*") -or
|
($pinnedItem.desktopAppLink -like "*Microsoft Edge*") -or
|
||||||
[System.Linq.Enumerable]::Any(
|
[System.Linq.Enumerable]::Any(
|
||||||
@(
|
@(
|
||||||
|
@ -34,13 +33,7 @@ foreach ($pinnedItem in $startLayout.pinnedList) {
|
||||||
[System.Func[System.Object,bool]]{
|
[System.Func[System.Object,bool]]{
|
||||||
param($pattern)
|
param($pattern)
|
||||||
return $pinnedItem.packageAppId -like "$pattern";
|
return $pinnedItem.packageAppId -like "$pattern";
|
||||||
})) {
|
}));
|
||||||
$removalQueue += @($pinnedItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($item in $removalQueue) {
|
|
||||||
$startLayout.pinnedList -= $item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$startLayout | ConvertTo-Json | Set-Content $startLayoutFile;
|
$startLayout | ConvertTo-Json | Set-Content $startLayoutFile;
|
||||||
|
|
Loading…
Reference in a new issue