Using Powershell to check for hotfixes

OK, nothing really new here to anyone who has played much with powershell but I gave myself a pat on the back for it.

If you want to check what hotfixes are installed on your machines, you can use the following command:

( get-adcomputer -filter *) | ForEach-Object -process {out-file -filepath c:\hotfixes.txt -append -inputobject (get-hotfix -computer $_.Name)}

Of course that is going to return a pretty long list if you have a lot of machines and/or hotfixes, so if you only wanted to check computers who names start with “server”, you could do:

( get-adcomputer -filter  ‘Name -like “server*”‘) | ForEach-Object -process {out-file -filepath c:\hotfixes.txt -append -inputobject (get-hotfix  -id KB976902 -computer $_.Name)}

And if you only want to check for a specific hotfix on those servers, you could do

( get-adcomputer -filter  ‘Name -like “server*”‘) | ForEach-Object -process {out-file -filepath c:\hotfixes.txt -append -inputobject (get-hotfix  -id KB976902 -computer $_.Name)}

It should of course have some error handling make sure that the ActiveDirectory module is loaded (you can check by running “Get-module -list”).

You do NOT need powershell installed on your target workstations/servers for this to work!

 

Advertisements

Leave a comment

Filed under Powershell, Windows 2008

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s