Данная проблема вызвана сбоем службы автоматического обновления Windows, в частности при работе с серверами обновлений WSUS.
Пошаговое решение проблемы выглядит так:
- Остановка службы обновлений (wuauserv)
- Остановка службы trustedinstaller
- Удаление содержимого папки c:\windows\temp
- Удаление cab-файлов из папки c:\windows\logs\CBS
- Удаление папки C:\windows\softwaredistribution
- Запуск сервиса trustedinstaller
- Запуск службы обновления
Для удаленного автоматического решения проблемы можно воспользоваться скриптом:
$Machine = read-host "Type in the Computer Name"
$windowsUpdateService = 'wuauserv'
$trustedInstallerService = 'trustedinstaller'
function Set-ServiceState
{
[CmdletBinding()]
param(
[string]$ComputerName,
[string]$ServiceName
)
Write-Verbose "Evaluating $ServiceName on $ComputerName."
[string]$WaitForIt = ""
[string]$Verb = ""
[string]$Result = "FAILED"
$svc = Get-Service -computername $ComputerName -name $ServiceName
Switch ($svc.status) {
'Stopped' {
Write-Verbose "[$ServiceName] is currently Stopped. Starting."
$Verb = "start"
$WaitForIt = 'Running'
$svc.Start()
}
'Running' {
Write-Verbose "[$ServiceName] is Running. Stopping."
$Verb = "stop"
$WaitForIt = 'Stopped'
$svc.Stop()
}
default {
Write-Verbose "$ServiceName is $($svc.status). Taking no action."
}
}
if ($WaitForIt -ne "") {
Try { # For some reason, we cannot use -ErrorAction after the next statement:
$svc.WaitForStatus($WaitForIt,'00:02:00')
} Catch {
Write-Warning "After waiting for 2 minutes, $ServiceName failed to $Verb."
}
$svc = (get-service -computername $ComputerName -name $ServiceName)
if ($svc.status -eq $WaitForIt) {
$Result = 'SUCCESS'
}
Write-Verbose "$Result - $ServiceName on $ComputerName is $($svc.status)"
Write-Verbose ("{0} - {1} on {2} is {4}" -f $Result, $ServiceName, $ComputerName, $svc.status)
}
}
# stop update service
Write-Host "stop update service"
Set-ServiceState -ComputerName $Machine -ServiceName $windowsUpdateService -Verbose
#removes temp files and renames software distribution folder
Write-Host "removes temp files and renames software distribution folder"
Remove-Item \\$Machine\c$\windows\temp\* -recurse
Rename-Item \\$Machine\c$\windows\SoftwareDistribution SoftwareDistribution.old
#restarts update service
Write-Host "restarts update service"
Set-ServiceState -ComputerName $Machine -ServiceName $windowsUpdateService
#removes software distribution.old
Write-Host "removes software distribution.old"
Remove-Item \\$Machine\c$\windows\SoftwareDistribution.old -recurse
#stops trustedinstaller service
Write-Host "stops trustedinstaller service"
Set-ServiceState -ComputerName $Machine -ServiceName $trustedInstallerService
#removes cab files from trustedinstaller
Write-Host "removes cab files from trustedinstaller"
remove-item \\$Machine\c$\windows\Logs\CBS\* -recurse
#restarts trustedinstaller service
Write-Host "restarts trustedinstaller service"
Set-ServiceState -ComputerName $Machine -ServiceName $trustedInstallerService
#rebuilds cab files from WSUS
Write-Host "rebuilds cab files from WSUS"
invoke-command -ComputerName $Machine -ScriptBlock { & cmd.exe "c:\windows\system32\wuauclt.exe /detectnow" }