Ensure keys for accessing adware options exist

This commit is contained in:
Manuel Thalmann 2023-07-19 01:46:32 +02:00
parent dffb937078
commit 1505cd3e94

View file

@ -23,6 +23,21 @@ $action = {
Copy-ItemProperty "HKCU:\$relativeKeyPath" "$keyPath" "$spacingProperty";
Rename-ItemProperty $keyPath $spacingProperty "_$spacingProperty";
Set-ItemProperty $keyPath -Name $spacingProperty -Value "-1710" -Type "String";
Write-Information "Disabling adware";
$contentDeliveryKey = "$($userKey.PSPath)\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager";
$cloudContentKey = "HKLM:\Software\Policies\Microsoft\Windows\CloudContent";
foreach ($key in @($contentDeliveryKey, $cloudContentKey)) {
if (-not (Test-Path $key)) {
$null = New-Item $key;
}
}
Set-ItemProperty "$cloudContentKey" -Name "DisableWindowsConsumerFeatures" -Value 1 -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";
}
$context.ProcessDefaultUserKey($action);
@ -58,11 +73,5 @@ $startLayout | Add-Member -NotePropertyName "primaryOEMPins" -NotePropertyValue
$startLayout | ConvertTo-Json -Compress | Set-Content "$env:SystemDrive\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.json";
$contentDeliveryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager";
Set-ItemProperty "HKLM:\Software\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Value 1 -Type "DWord";
Set-ItemProperty "$contentDeliveryPath" -Name "ContentDeliveryAllowed" -Value 0 -Type "DWord";
Set-ItemProperty "$contentDeliveryPath" -Name "SilentInstalledAppsEnabled" -Value 0 -Type "DWord";
Set-ItemProperty "$contentDeliveryPath" -Name "SystemPaneSuggestionsEnabled" -Value 0 -Type "DWord";
Pop-Location;
Remove-Item -Recurse "$tempDir";