PortValhalla/scripts/Windows/Config/Windows/Install.ps1

82 lines
3.1 KiB
PowerShell
Raw Normal View History

2023-07-17 14:02:33 +00:00
#!/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";
2023-07-18 20:27:32 +00:00
$context.RemoveDesktopIcon("Microsoft Edge*");
2023-07-17 14:02:33 +00:00
Write-Host "Configuring Windows";
$action = {
param([Microsoft.Win32.RegistryKey] $userKey)
$spacingProperty = "IconSpacing";
2023-07-17 14:12:26 +00:00
$relativeKeyPath = "Control Panel\Desktop\WindowMetrics"
$keyPath = "$($userKey.PSPath)\$relativeKeyPath";
Write-Information "Setting old-school Desktop Icon Size";
2023-07-17 14:12:26 +00:00
Copy-ItemProperty "HKCU:\$relativeKeyPath" "$keyPath" "$spacingProperty";
2023-07-17 14:02:33 +00:00
Rename-ItemProperty $keyPath $spacingProperty "_$spacingProperty";
Set-ItemProperty $keyPath -Name $spacingProperty -Value "-1710" -Type "String";
Write-Information "Disabling adware";
2023-07-19 14:01:29 +00:00
$winKey = "$($userKey.PSPath)\Software\Microsoft\Windows\CurrentVersion";
$contentDeliveryKey = "$winKey\ContentDeliveryManager";
$cloudContentKey = "HKLM:\Software\Policies\Microsoft\Windows\CloudContent";
foreach ($key in @($contentDeliveryKey, $cloudContentKey)) {
if (-not (Test-Path $key)) {
$null = New-Item $key;
}
}
2023-07-29 19:13:38 +00:00
# Set-ItemProperty "$cloudContentKey" -Name "DisableWindowsConsumerFeatures" -Value 1 -Type "DWord";
2023-07-19 07:11:53 +00:00
Set-ItemProperty "$cloudContentKey" -Name "DisableCloudOptimizedContent" -Value 1 -Type "DWord";
Set-ItemProperty "$cloudContentKey" -Name "DisableConsumerAccountStateContent" -Value 1 -Type "DWord";
2023-07-19 14:01:29 +00:00
Set-ItemProperty "$winKey\Explorer\Advanced" -Name "TaskBarMn" -Value 0 -Type "DWord";
Set-ItemProperty "$contentDeliveryKey" -Name "ContentDeliveryAllowed" -Value 0 -Type "DWord";
Set-ItemProperty "$contentDeliveryKey" -Name "SilentInstalledAppsEnabled" -Value 0 -Type "DWord";
Set-ItemProperty "$contentDeliveryKey" -Name "SystemPaneSuggestionsEnabled" -Value 0 -Type "DWord";
2023-07-17 14:02:33 +00:00
}
$context.ProcessDefaultUserKey($action);
Write-Information "Remove ads from pinned apps";
Export-StartLayout $startLayoutFile;
2023-07-18 21:46:03 +00:00
$startLayout = Get-Content "$startLayoutFile" | ConvertFrom-Json
$originalProperty = "pinnedList";
2023-07-18 22:16:13 +00:00
$newLayout = $startLayout | Select-Object -ExpandProperty $originalProperty | Where-Object {
return -not (
($_.desktopAppLink -like "*Microsoft Edge*") -or
[System.Linq.Enumerable]::Any(
@(
"*MicrosoftOfficeHub*",
"*SpotifyMusic*",
"*WhatsApp*",
"*PrimeVideo*",
"*Netflix*",
"*Instagram*",
"*Clipchamp*",
2023-07-18 20:30:19 +00:00
"*Facebook*",
"*LinkedIn*"),
[System.Func[System.Object,bool]]{
param($pattern)
return $_.packagedAppId -like "$pattern";
}));
}
2023-07-18 21:46:03 +00:00
$startLayout.PSObject.Properties.Remove($originalProperty);
$startLayout | Add-Member -NotePropertyName "primaryOEMPins" -NotePropertyValue $newLayout;
2023-07-18 21:50:27 +00:00
$startLayout | ConvertTo-Json -Compress | Set-Content "$env:SystemDrive\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.json";
Pop-Location;
Remove-Item -Recurse "$tempDir";