Disables all background activity for modern UWP apps by setting 'GlobalUserDisabled' to 1 under the current user's BackgroundAccessApplications registry key, creating the key if it doesn't exist.
$path="HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications"$name="GlobalUserDisabled"$newValue=1# Ensure the key existsIf(-Not(Test-Path$path)){New-Item-Path$path-Force|Out-Null}# Set the valueSet-ItemProperty-Path$path-Name$name-TypeDWord-Value$newValueWrite-Host"$name set to $newValue (Background Access Disabled)"
$path="HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications"$name="GlobalUserDisabled"$originalValue=0# Ensure the key existsIf(-Not(Test-Path$path)){New-Item-Path$path-Force|Out-Null}# Revert the valueSet-ItemProperty-Path$path-Name$name-TypeDWord-Value$originalValueWrite-Host"$name reverted to $originalValue (Background Access Restored)"-ForegroundColorYellow