Home > Powershell > Using Powershell to query for installed KB’s

Using Powershell to query for installed KB’s

I was recently trying to install Powershell  v2 CTP 3 which requires that certain hotfixes (KB’s) be installed first.  I’m always switching from project to project so I wasn’t sure if the KB’s on one particular server were installed.

I first used the command line utility Systeminfo which displays a list of installed KB’s as seen below:

Although this proved useful I wondered if this was possible using Powershell.  Since I didn’t yet know how to do this using Powershell I had to do a Google search.  I was able to find some code and then posted it on the Microsoft.Public.Windows.Powershell newsgroup.  The title is “Search for installed patches” and it was posted on 12/30/2009.  I got some responses but they didn’t provide what I needed.  It just so happens that I was viewing a TechNet Virtual Lab called “Writing Scripts with Powershell” which provided some useful information on how I could format the curent code to display the results I was looking for as seen below:

Not only was I able to display a list of all hotfixes but was able to append to the script a specific hotfix which, if installed would display an output of 1.

I would like to now query for more then just one KB and display the KB’s by name and color (green=installed, red=not installed).  I posted the additional info on the newsgroup and hope they can help but if not I might find the answer in the next video.  Anyway, here is the code so far:

Categories: Powershell
  1. alex
    November 24, 2011 at 12:14 am

    There is an alternative: built-in CMDLET called get-hotfix but it seems to work if KB exists, but a bit spotty if it doesnt.

    • alex
      November 24, 2011 at 12:22 am

      if(!(hotfix | ?{$_ -match “kb980368”})){“not exist”}

      There, much better

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: