Commit 7e26b8cc authored by Stefan Scherer's avatar Stefan Scherer

added try/catch around SearchResult .. Format-List

parent 0483c784
......@@ -186,8 +186,17 @@ function Check-WindowsUpdates() {
}
if ($SearchResult.Updates.Count -ne 0) {
$script:SearchResult.Updates |Select-Object -Property Title, Description, SupportUrl, UninstallationNotes, RebootRequired, EulaAccepted |Format-List
$global:MoreUpdates=1
$Message = "There are " + $SearchResult.Updates.Count + " more updates."
LogWrite $Message
try {
$script:SearchResult.Updates |Select-Object -Property Title, Description, SupportUrl, UninstallationNotes, RebootRequired, EulaAccepted |Format-List
$global:MoreUpdates=1
} catch {
LogWrite $_.Exception | Format-List -force
LogWrite "Showing SearchResult was unsuccessful. Aborting."
$global:RestartRequired=0
$global:MoreUpdates=0
}
} else {
LogWrite 'There are no applicable updates'
$global:RestartRequired=0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment