2021-12-02 10:56:43 +03:00
|
|
|
################################################################################
|
2023-11-16 11:20:11 +01:00
|
|
|
## File: Install-WindowsUpdatesAfterReboot.ps1
|
|
|
|
|
## Desc: Waits for Windows Updates to finish installing after reboot
|
2021-12-02 10:56:43 +03:00
|
|
|
################################################################################
|
|
|
|
|
|
2023-11-29 12:58:37 +01:00
|
|
|
Invoke-ScriptBlockWithRetry -RetryCount 10 -RetryIntervalSeconds 120 -Command {
|
2023-11-27 12:29:42 +01:00
|
|
|
$inProgress = Get-WindowsUpdateStates | Where-Object State -eq "Running" | Where-Object Title -notmatch "Microsoft Defender Antivirus"
|
2021-12-02 10:56:43 +03:00
|
|
|
if ( $inProgress ) {
|
|
|
|
|
$title = $inProgress.Title -join "`n"
|
2023-11-27 12:29:42 +01:00
|
|
|
throw "Windows updates are still installing: $title"
|
2021-12-02 10:56:43 +03:00
|
|
|
}
|
|
|
|
|
}
|