Well I finally got the VM updated using a combination of nearly every suggestion. If I'd got all the time in the world, I'd go back to the snapshot to try and repeat but in the end it was a mad combination of:
- Changing the four services mentioned above to auto - note... Windows keeps resetting the start mode for the bits service to manual
- Stopping the wuauserv and bits services and then deleting the SoftwareDistribution folder
- Rebooting many times
- Installing the update manually
On the last attempt, I ran the PowerShell script below, installed KB4093112 (Apr 2018 updates) manually and rebooted - at least twice. First time it installed a few things but still said a restart was needed so another restart installed some more stuff and
finally said "Up to date" with winver showing Version 1709 (OS Build 16299.371).
What a palaver!
Fix-WindowsUpdate.ps1 - attempts to repair culmulative update failures.
Check running as administrator.
$User = [Security.Principal.WindowsIdentity]::GetCurrent()
If (!((New-Object Security.Principal.WindowsPrincipal $User).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))) {
Write-Host -Fore Red "Please run as administrator"
Return
}
Change services to auto but also stop them.
$ServiceNames = @("wuauserv","bits","cryptsvc","trustedinstaller")
ForEach ($ServiceName In $ServiceNames) {
$Service = Get-Service -Name $ServiceName
If ($Service.StartType -ne "Automatic") {
Write-Host "Changing $ServiceName to automatic"
$Cmd = "cmd /c SC config $ServiceName start= auto"
Invoke-Expression $Cmd
}
# Write-Host "$ServiceName`: $($Service.Status)"
If ($Service.Status -eq "Running") {
Write-Host "Stopping $ServiceName"
$Service | Stop-Service
}
}
Delete software distribution folder.
$Path = $Env:WinDir + "\SoftwareDistribution"
If (Test-Path $Path) {
Write-Host "Removing $Path"
Remove-Item -Path $Path -Recurse -Force
}
If (Test-Path $Path) {Write-Host -Fore Yellow "WARNING: folder not entirely deleted"}
Finished.
Write-Host -Fore Yellow "Run again if errors, otherwise restart"