Blog
By Pete Zerger on 2/20/2010 7:05:47 AM • Rank (3910) • Views 4064
0

0

By request of Mattie, here is some PowerShell on how to query hotfixes installed on a computer, as well as script to connect to a list of remote computers to determine whether or not a hotfix is installed.

List all installed hotfixes on local machine

Get-WmiObject -query 'select * from win32_quickfixengineering' | foreach {$_.hotfixid} 

Search for a specific hotfix.

This example will find if KB976749 is installed, returning 1 if yes, 0 if no.

Get-WmiObject -query 'select * from win32_quickfixengineering' | where {$_.hotfixid -eq "KB976749"} | 
foreach {$_.hotfixid}

Check list of remote machines for a specific hotfix

This script reads the comma-delimited list of computers assigned to the variable on line 1. It quietly continues if it cannot connect, and if it does, returns message to screen with message about whether the hotfix is installed.

To run, save in Notepad with a .ps1 extension and run from PowerShell prompt. Update the list of computers with your desired list

$boxes="pzerger-01","pzerger-pc","127.0.0.1"

foreach ($box in $boxes)
{

if (Get-WmiObject -Computer $box -Class Win32_QuickFixEngineering `
-Filter "HotFixID='KB976749'" -erroraction silentlycontinue)

{Write-Host "$box has KB976749 installed"}

else

{Write-Host "Cannot connect to computer or KB976749 not installed on $box"}


}

Conclusion

Checking for hotfixes in PowerShell is quite easy. Let me know if there are any specific scenarios with PowerShell and hotfixes you'd like to see.

Comments - Comment RSS


Who Viewed
Who Reviewed
Categories
Related Pages
Shortened URL
http://tinyurl.com/ygj7gbf

Top Contributors
Featured Members
Pete Zerger
Points: 65622
Level: System Center Expert
Tommy Gunn
Points: 42748
Level: System Center Expert
Simon Skinner
Points: 40804
Level: System Center Expert
Stefan Koell
Points: 28999
Level: System Center Expert
Andreas Zuckerhut
Points: 27734
Level: System Center Expert