Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. $REGKEY="HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindowsWindowsUpdate"
  2. $REGITEM = "DoNotConnectToWindowsUpdateInternetLocations"
  3.  
  4. function Set-RegistryItem {
  5. param (
  6. # Registry key to set
  7. [Parameter(Mandatory=$true)]
  8. [string]
  9. $RegistryKey,
  10.  
  11. # Registry item to set
  12. [Parameter(Mandatory=$true)]
  13. [string]
  14. $RegistryItem,
  15.  
  16. # Value to Set
  17. [Parameter(Mandatory=$true)]
  18. [string]
  19. $Value,
  20.  
  21. # Value type to Set
  22. [Parameter(Mandatory=$true)]
  23. [string]
  24. $Type
  25. )
  26.  
  27. if ($(Get-ItemProperty -Path Registry::$RegistryKey -Name $RegistryItem)) {
  28. New-ItemProperty -Path Registry::$RegistryKey -Name $RegistryItem -PropertyType $Type -Value $Value -Confirm -Force
  29. }
  30. }
  31.  
  32. Set-RegistryItem `
  33. -RegistryKey "HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindowsWindowsUpdate" `
  34. -RegistryItem DoNotConnectToWindowsUpdateInternetLocations `
  35. -Value 0 `
  36. -Type DWord
  37.  
  38. Set-RegistryItem `
  39. -RegistryKey HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindowsStore `
  40. -RegistryItem AutoDownload `
  41. -Value 4 `
  42. -Type DWord
  43.  
  44. Set-RegistryItem `
  45. -RegistryKey HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindowsStore `
  46. -RegistryItem RemoveWindowsStore `
  47. -Value 0 `
  48. -Type DWord
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement