Advertisement
SHADOWOPS

Disable/Enable Razr automatic download of Synapse

Feb 4th, 2024
1,538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.67 KB | Cybersecurity | 0 0
  1. # Check for elevated privileges
  2. if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
  3.     Write-Error "This script must be run as an Administrator. Please run it again with elevated privileges."
  4.     exit
  5. }
  6.  
  7. param(
  8.     [Parameter(Mandatory=$true)]
  9.     [ValidateSet("Enable","Disable")]
  10.     [string]$Action
  11. )
  12.  
  13. function Backup-Registry {
  14.     $backupFile = "HKLM_SOFTWARE_Policies_Microsoft_Windows_DeviceInstall_Settings.reg"
  15.     reg export "HKLM\SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Settings" $backupFile
  16.     Write-Host "Registry backup created: $backupFile"
  17. }
  18.  
  19. function Set-DeviceInstallPolicy {
  20.     param([string]$Action)
  21.    
  22.     Backup-Registry
  23.    
  24.     $path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Settings"
  25.     $disableSystemUpdateAccessValue = if ($Action -eq "Disable") { 1 } else { 0 }
  26.     $disableDeviceMetadataRetrievalValue = if ($Action -eq "Disable") { 1 } else { 0 }
  27.    
  28.     New-ItemProperty -Path $path -Name "DisableSystemUpdateAccess" -Value $disableSystemUpdateAccessValue -PropertyType DWord -Force | Out-Null
  29.     New-ItemProperty -Path $path -Name "DisableDeviceMetadataRetrieval" -Value $disableDeviceMetadataRetrievalValue -PropertyType DWord -Force | Out-Null
  30.    
  31.     if ($Action -eq "Disable") {
  32.         Write-Host "Automatic downloading of manufacturer apps and custom icons is now disabled."
  33.     } else {
  34.         Write-Host "Automatic downloading of manufacturer apps and custom icons is now enabled."
  35.     }
  36. }
  37.  
  38. # Execute the function with the provided action
  39. Set-DeviceInstallPolicy -Action $Action
Tags: Razr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement