From c5536c7c75fafa99fbabfef030727aa0596d7e4a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 18 Jul 2023 21:19:49 +0200 Subject: [PATCH] Remove ads from Windows before creating user --- scripts/Windows/Collections/Personal.ps1 | 1 - scripts/Windows/Config/Windows/Install.ps1 | 42 ++++++++++++++++++ .../Windows/Config/Windows/InstallUser.ps1 | 43 ------------------- 3 files changed, 42 insertions(+), 44 deletions(-) delete mode 100644 scripts/Windows/Config/Windows/InstallUser.ps1 diff --git a/scripts/Windows/Collections/Personal.ps1 b/scripts/Windows/Collections/Personal.ps1 index 9a029bc7..73ca70fd 100644 --- a/scripts/Windows/Collections/Personal.ps1 +++ b/scripts/Windows/Collections/Personal.ps1 @@ -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 diff --git a/scripts/Windows/Config/Windows/Install.ps1 b/scripts/Windows/Config/Windows/Install.ps1 index 44efb54c..4a2ae8c4 100644 --- a/scripts/Windows/Config/Windows/Install.ps1 +++ b/scripts/Windows/Config/Windows/Install.ps1 @@ -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"; diff --git a/scripts/Windows/Config/Windows/InstallUser.ps1 b/scripts/Windows/Config/Windows/InstallUser.ps1 deleted file mode 100644 index a1ae6619..00000000 --- a/scripts/Windows/Config/Windows/InstallUser.ps1 +++ /dev/null @@ -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";