Skip to content

Instantly share code, notes, and snippets.

@nexocentric
Created January 20, 2020 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nexocentric/2b532b16ffa9d6e1a0072cee9553dd9e to your computer and use it in GitHub Desktop.
Save nexocentric/2b532b16ffa9d6e1a0072cee9553dd9e to your computer and use it in GitHub Desktop.
$REGKEY="HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
$REGITEM = "DoNotConnectToWindowsUpdateInternetLocations"
function Set-RegistryItem {
param (
# Registry key to set
[Parameter(Mandatory=$true)]
[string]
$RegistryKey,
# Registry item to set
[Parameter(Mandatory=$true)]
[string]
$RegistryItem,
# Value to Set
[Parameter(Mandatory=$true)]
[string]
$Value,
# Value type to Set
[Parameter(Mandatory=$true)]
[string]
$Type
)
if ($(Get-ItemProperty -Path Registry::$RegistryKey -Name $RegistryItem)) {
New-ItemProperty -Path Registry::$RegistryKey -Name $RegistryItem -PropertyType $Type -Value $Value -Confirm -Force
}
}
Set-RegistryItem `
-RegistryKey "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" `
-RegistryItem DoNotConnectToWindowsUpdateInternetLocations `
-Value 0 `
-Type DWord
Set-RegistryItem `
-RegistryKey HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsStore `
-RegistryItem AutoDownload `
-Value 4 `
-Type DWord
Set-RegistryItem `
-RegistryKey HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsStore `
-RegistryItem RemoveWindowsStore `
-Value 0 `
-Type DWord
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment