-
Notifications
You must be signed in to change notification settings - Fork 161
/
Stop-UpdateServices.ps1
30 lines (27 loc) · 1.25 KB
/
Stop-UpdateServices.ps1
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
function Stop-UpdateServices {
Write-BoxstarterMessage "Disabling Automatic Updates from Windows Update"
$winUpdateKey = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\au"
if(!(Test-Path $winUpdateKey) ) { New-Item $winUpdateKey -Type Folder -Force | Out-Null }
Remove-BoxstarterError {
# Backup original value
Rename-ItemProperty -Path $winUpdateKey -Name 'NoAutoUpdate' -NewName 'NoAutoUpdate_BAK'
New-ItemProperty -Path $winUpdateKey -name 'NoAutoUpdate' -value '1' -propertyType "DWord" -force | Out-Null
New-ItemProperty -Path $winUpdateKey -name 'NoAutoRebootWithLoggedOnUsers' -value '1' -propertyType "DWord" -force | Out-Null
}
Stop-CCMEXEC
}
function Stop-CCMEXEC {
$ccm = (Get-Service -include CCMEXEC)
if($ccm) {
Set-Service CCMEXEC -startuptype disabled
do {
if($ccm.CanStop) {
Write-boxstartermessage "Stopping Configuration Manager"
Enter-BoxstarterLogable { Stop-Service CCMEXEC }
return
}
Write-boxstartermessage "Waiting for Computer Configuration Manager to stop..."
sleep 10
} while (-not ($ccm.CanStop) -and ($i++ -lt 5))
}
}