Provisioning: Fix disabling windows updates

On some machines the updates were already disabled, which lead
to the call to disable the service failing. Now we just move on without
error.

Change-Id: Ia48f7164c23dfe24e24548558d582cdc0190b7e3
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
This commit is contained in:
Oliver Wolff
2018-01-17 15:57:27 +01:00
committed by Frederik Gladhorn
parent b86b3a757b
commit 99595f44f1

View File

@@ -33,5 +33,22 @@
# This script disables the automatic Windows updates
stop-service wuauserv
set-service wuauserv <EFBFBD>startup disabled
$service = get-service wuauserv
if (-not $service) {
Write-Host "Windows Update service not found."
exit 0
}
if ($service.Status -eq "Stopped") {
Write-Host "Windows Update service already stopped."
} else {
Write-Host "Stopping Windows Update service."
stop-service wuauserv
}
$startup = Get-WmiObject Win32_Service | Where-Object {$_.Name -eq "wuauserv"} | Select -ExpandProperty "StartMode"
if ($startup -ne "Disabled") {
set-service wuauserv -startup disabled
} else {
Write-Host "Windows Update service startup already disabled."
}