AsBuiltReport.Veeam.VBR icon indicating copy to clipboard operation
AsBuiltReport.Veeam.VBR copied to clipboard

Add Windows Update Missing Patches

Open rebelinux opened this issue 1 year ago • 0 comments
trafficstars

Description

Add Windows Update Missing Patches to the report.

try {
    $UpdObj = @()
    $Updates = Invoke-Command -Session $TempPssSession -ScriptBlock { (New-Object -ComObject Microsoft.Update.Session).CreateupdateSearcher().Search("IsHidden=0 and IsInstalled=0").Updates | Select-Object Title, KBArticleIDs }
    $UpdObj += if ($Updates) {
        $OutObj = @()
        foreach ($Update in $Updates) {
            try {
                $inObj = [ordered] @{
                    'KB Article' = "KB$($Update.KBArticleIDs)"
                    'Name' = $Update.Title
                }
                $OutObj += [pscustomobject]$inobj

                if ($HealthCheck.OperatingSystem.Updates) {
                    $OutObj | Set-Style -Style Warning
                }
            } catch {
                Write-PScriboMessage -IsWarning $_.Exception.Message
            }
        }
        $TableParams = @{
            Name = "Missing Windows Updates"
            List = $false
            ColumnWidths = 40, 60
        }
        if ($Report.ShowTableCaptions) {
            $TableParams['Caption'] = "- $($TableParams.Name)"
        }
        $OutObj | Sort-Object -Property 'Name' | Table @TableParams
    }
    if ($UpdObj) {
        Section -Style Heading3 'Missing Windows Updates' {
            Paragraph "The following section provides a summary of pending/missing windows updates."
            BlankLine
            $UpdObj
        }
    }
} catch {
    Write-PScriboMessage -IsWarning $_.Exception.Message
}

Additional Context

Requested by User (email)

Before submitting

  • [X] I have read the documentation, and referred to the known issues before submitting this change request.
  • [X] I have checked for previously opened & closed issues before submitting this change request.

rebelinux avatar Apr 15 '24 15:04 rebelinux