Repository navigation
Expand file tree
/
Copy pathDisableScript.ps1
More file actions
42 lines (34 loc) · 1.96 KB
/
Copy pathDisableScript.ps1
File metadata and controls
42 lines (34 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Write-Host "Windows Update is Disabling..."
sc.exe config wuauserv start=disabled
sc.exe stop wuauserv
$AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
$AUSettings.NotificationLevel = 1
$AUSettings.Save
# Disable Windows Update service using Group Policy
$groupPolicyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
$groupPolicyValueName = "DisableWindowsUpdateAccess"
$groupPolicyValue = 1
if (!(Test-Path $groupPolicyPath)) {
New-Item -Path $groupPolicyPath -Force | Out-Null
}
Set-ItemProperty -Path $groupPolicyPath -Name $groupPolicyValueName -Value $groupPolicyValue
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
$registryValueName = "NoAutoUpdate"
$registryValue = 1
# Create AU registry key if it doesn't exist
if (-not (Test-Path -Path $registryPath)) {
New-Item -Path $registryPath -Force | Out-Null
}
# Set Windows Update registry value to disable
Set-ItemProperty -Path $registryPath -Name $registryValueName -Value $registryValue
# Stop and disable Windows Update service
Stop-Service -Name "wuauserv"
# Set Windows Update service startup type to disabled
Set-Service -Name "wuauserv" -StartupType Disabled
$wsusServer = "http://localhost:8530"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUServer" -Value $wsusServer
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUStatusServer" -Value $wsusServer
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ElevateNonAdmins" -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "TargetGroup" -Value "WSUS Group"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "TargetGroupEnabled" -Value 1
Restart-Service -Name "wuauserv"