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

63 lines
2 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";
Write-Information "Set old-school icon size";
2023-07-17 14:02:33 +00:00
$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";
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";
}
$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 21:46:03 +00:00
$newLayout = $startLayout[$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;
$startLayout | ConvertTo-Json -Compress | Set-Content "$env:SystemDrive\Users\Default\AppData\Local\Microsoft\Windows\Shell";
Pop-Location;
Remove-Item -Recurse "$tempDir";