top of page

PowerShell - Get HotFix (KB) Report

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 12, 2022
  • 1 min read

Save as GetHotFixReport.ps1, or as desired, gets HostName, If Reachable, Last Boot Time, Last 5 Hot Fixes or KB's installed (Configurable), Last patch installed on date, Installed by, Description and the Current auto stopped services of servers populated in c:\temp\servers.txt

$comp= gc "c:\temp\servers.txt"

$infoObject=@()

$results=@()

foreach($co in $comp)

{

$co

$css = @"

<style>

h1, h5, th { text-align: center; font-family: Segoe UI; }

table { margin: auto; font-family: Segoe UI; box-shadow: 10px 10px 5px #888; border: thin ridge grey; }

th { background: #0046c3; color: #fff; max-width: 400px; padding: 5px 10px; }

td { font-size: 11px; padding: 5px 20px; color: #000; }

tr { background: #b8d1f3; }

tr:nth-child(even) { background: #dae5f4; }

tr:nth-child(odd) { background: #b8d1f3; }

</style>

"@

$infoObject = New-Object PSObject

$p=Test-Connection -ComputerName $co -BufferSize 16 -Count 1 -Quiet

$p

$hotfix= Get-WmiObject -Class Win32_quickfixengineering -ComputerName $co |select Hotfixid -Last 5

$h=($hotfix|select @{Name="fixes" ;expression={$hotfix.hotfixid -join ","}} -Last 1).fixes

$h

$description = Get-WmiObject -Class Win32_quickfixengineering -ComputerName $co|select -ExpandProperty Description -last 1

$description

$installedby = Get-WmiObject -Class Win32_quickfixengineering -ComputerName $co|select -ExpandProperty Installedby -last 1

$installedby

$installedon = Get-WmiObject -Class Win32_quickfixengineering -ComputerName $co|select -ExpandProperty Installedon -last 1

$installedon

$Boottime = Get-WmiObject -Class Win32_operatingsystem -ComputerName $co |select -ExpandProperty LastBootUpTime

$b = ($Boottime|select @{Name="LastBootUpTime" ;EXPRESSION={$co.ConverttoDateTime}}.Lastbootuptime)

$b

$service = Get-WmiObject -ClassName Win32_Service -Filter "StartMode='Auto' AND State<>'Running'" -computername $co

$r = ($service|select @{Name="Service" ;expression={$service.name -join ","}} -Last 1).service

$r

$infoObject|Add-Member -MemberType NoteProperty -Name "Hostname" -value $co

$infoObject|Add-Member -MemberType NoteProperty -Name "Reachable" -value $p

$infoObject|Add-Member -MemberType NoteProperty -Name "Last Boot Up Time" -value $b

$infoObject|Add-Member -MemberType NoteProperty -Name "Hotfix ID" -Value $h

$infoObject|Add-Member -MemberType NoteProperty -Name "Last Patch Installed On" -Value $installedon

$infoObject|Add-Member -MemberType NoteProperty -Name "Installed By" -Value $installedby

$infoObject|Add-Member -MemberType NoteProperty -Name "Description" -Value $description

$infoObject|Add-Member -MemberType NoteProperty -Name "Current Auto Stopped services" -Value $r


$results+=$infoObject

}


$results | Export-Csv c:\temp\ServerHotfixReport.csv


 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page