Thursday, May 17, 2012

PowerShell: Searching For Installed Patches/Updates

I had the need to search for the installation of specific patches on one of my servers recently. This isn't really a big deal...just type "appwiz.cpl" into the Run window and click "View Installed Updates" or take the dangerous journey through the control panel to find the same thing)...

However, even in Windows Server 2008, there is no option to sort this list by KB article (patch name). So what to do?

Hello, PowerShell! Nice to meet you again!



$KB = Read-Host "Enter KB Number (EX: KB2604094, with or without KB): "

 If ($KB.StartsWith("KB", "CurrentCultureIgnoreCase"))
  { $KB = $KB.Substring(2) }
 
 $Result = Get-HotFix | Where {$_.HotFixID -like "*$KB*"} | Select Description, HotFixID, InstalledBy, InstalledOn | Format-List
 
 If ($Result.Count -gt 0) { $Result }
 Else { Write-Host "KB Not Found!" }


Just enter any part of the HotFix ID that want. Here is the output. It's messy, but it gets the job done.


No comments:

Post a Comment