komputertipsdotcom

Disable lewat PowerShell (www.komputertips.com)

Feb 15th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Clear-Host
  2.  
  3. Write-Host "0 -> Change setting in Windows Update app (default)"
  4. Write-Host "1 -> Never check for updates (not recommended)"
  5. Write-Host "2 -> Notify for download and notify for install"
  6. Write-Host "3 -> Auto download and notify for install"
  7. Write-Host "4 -> Auto download and schedule the install"
  8.  
  9. Write-Host "Enter any character to exit"
  10. Write-Host
  11. switch(Read-Host "Choose Window Update Settings"){
  12.        0 {$UpdateValue = 0}
  13.        1 {$UpdateValue = 1}
  14.        2 {$UpdateValue = 2}
  15.        3 {$UpdateValue = 3}
  16.        4 {$UpdateValue = 4}
  17.        Default{Exit}
  18. }
  19.  
  20. $WindowsUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\"
  21. $AutoUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
  22.  
  23. If(Test-Path -Path $WindowsUpdatePath) {
  24.     Remove-Item -Path $WindowsUpdatePath -Recurse
  25. }
  26.  
  27.  
  28. If ($UpdateValue -gt 0) {
  29.     New-Item -Path $WindowsUpdatePath
  30.     New-Item -Path $AutoUpdatePath
  31. }
  32.  
  33. If ($UpdateValue -eq 1) {
  34.     Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 1
  35. }
  36.  
  37. If ($UpdateValue -eq 2) {
  38.     Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 0
  39.     Set-ItemProperty -Path $AutoUpdatePath -Name AUOptions -Value 2
  40.     Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallDay -Value 0
  41.     Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallTime -Value 3
  42. }
  43.  
  44. If ($UpdateValue -eq 3) {
  45.     Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 0
  46.     Set-ItemProperty -Path $AutoUpdatePath -Name AUOptions -Value 3
  47.     Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallDay -Value 0
  48.     Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallTime -Value 3
  49. }
  50.  
  51. If ($UpdateValue -eq 4) {
  52.     Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 0
  53.     Set-ItemProperty -Path $AutoUpdatePath -Name AUOptions -Value 4
  54.     Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallDay -Value 0
  55.     Set-ItemProperty -Path $AutoUpdatePath -Name ScheduledInstallTime -Value 3
  56. }
Add Comment
Please, Sign In to add comment