Remove ads from Windows before creating user

This commit is contained in:
Manuel Thalmann 2023-07-18 21:19:49 +02:00
parent 6fefa76532
commit c5536c7c75
3 changed files with 42 additions and 44 deletions

View file

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

View file

@ -1,6 +1,18 @@
#!/bin/pwsh
param($context)
. "$PSScriptRoot/../../Scripts/Context.ps1";
[Context] $context = $context;
$tempDir = $context.GetTempDirectory();
$startLayoutFile = "start.json";
Push-Location "$tempDir";
Write-Information "Remove MSEdge Icon";
$context.RemoveDesktopIcon("Microsoft Edge");
Write-Host "Configuring Windows";
Write-Information "Set old-school icon size";
$action = {
param([Microsoft.Win32.RegistryKey] $userKey)
@ -14,3 +26,33 @@ $action = {
}
$context.ProcessDefaultUserKey($action);
Write-Information "Remove ads from pinned apps";
Export-StartLayout $startLayoutFile;
$startLayout = Get-Content "$startLayoutFile" | ConvertFrom-Json;
$startLayout.pinnedList = $startLayout.pinnedList | Where-Object {
return -not (
($_.desktopAppLink -like "*Microsoft Edge*") -or
[System.Linq.Enumerable]::Any(
@(
"*MicrosoftOfficeHub*",
"*SpotifyMusic*",
"*WhatsApp*",
"*PrimeVideo*",
"*Netflix*",
"*Instagram*",
"*Clipchamp*",
"*Facebook*"),
[System.Func[System.Object,bool]]{
param($pattern)
return $_.packagedAppId -like "$pattern";
}));
}
$startLayout | ConvertTo-Json | Set-Content $startLayoutFile;
Import-StartLayout $startLayoutFile "$env:SystemDrive";
Pop-Location;
Remove-Item -Recurse "$tempDir";

View file

@ -1,43 +0,0 @@
#!/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;
$startLayout.pinnedList = $startLayout.pinnedList | Where-Object {
return -not (
($_.desktopAppLink -like "*Microsoft Edge*") -or
[System.Linq.Enumerable]::Any(
@(
"*MicrosoftOfficeHub*",
"*SpotifyMusic*",
"*WhatsApp*",
"*PrimeVideo*",
"*Netflix*",
"*Instagram*",
"*Clipchamp*",
"*Facebook*"),
[System.Func[System.Object,bool]]{
param($pattern)
return $_.packagedAppId -like "$pattern";
}));
}
$startLayout | ConvertTo-Json | Set-Content $startLayoutFile;
Import-StartLayout $startLayoutFile "$env:SystemDrive";
Pop-Location;
Remove-Item -Recurse "$tempDir";