Remove ads from Windows

This commit is contained in:
Manuel Thalmann 2023-07-18 20:51:11 +02:00
parent c0b8996960
commit 963245b967
2 changed files with 50 additions and 1 deletions

View file

@ -33,8 +33,8 @@ function Restore-PersonalApps([Context] $context) {
Install-PersonalDrivers $context;
}
. "$PSScriptRoot/../Config/Windows/InstallUser.ps1";
. "$PSScriptRoot/../Software/chocolatey/Install.ps1";
$context.RemoveDesktopIcon("Microsoft Edge");
# Backed up applications
Restore-Git $context;

View file

@ -0,0 +1,49 @@
#!/bin/pwsh
param($context)
. "$PSScriptRoot/../../Scripts/Context.ps1";
[Context] $context = $context;
$tempDir = $context.GetTempDirectory();
$startLayoutFile = "start.json";
Push-Location "$tempDir";
Write-Host "Configuring Windows for Users";
Write-Information "Remove MSEdge Icon";
$context.RemoveDesktopIcon("Microsoft Edge");
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 (
($pinnedItem.desktopAppLink -like "*Microsoft Edge*") -or
[System.Linq.Enumerable]::Any(
@(
"*MicrosoftOfficeHub*",
"*SpotifyMusic*",
"*WhatsApp*",
"*PrimeVideo*",
"*Netflix*",
"*Instagram*",
"*Chipchamp*",
"*Facebook*"),
{
param($pattern)
return $pinnedItem.packageAppId -like "$pattern";
})) {
$removalQueue += @($pinnedItem);
}
}
foreach ($item in $removalQueue) {
$startLayout.pinnedList.Remove($item);
}
$startLayout | ConvertTo-Json | Set-Content $startLayoutFile;
Pop-Location "$tempDir";
Remove-Item -Recurse "$tempDir";