header image

Last Hotfix Install date

Posted by: | February 27, 2010 | 2 Comments |

I was thinking about testing machines for when they were last patched and remembered that Get-Hotfix displays the Installed date for patches.  Unfortunately, it isn’t available for all patches so we can’t get a guaranteed last date of patching by this method.  However, we do get something close and if the script shows a date 3, 6 or worse months in the past we know we have some work to do.

".", "rslaptop01", "" | foreach { 
    Get-HotFix -ComputerName $_  | 
    Where {$_.InstalledOn} | 
    sort InstalledOn -Descending | 
    select CSname, @{Name="Installed"; 
    Expression={"{0:dd MMMM yyyy}" -f [datetime]$_.InstalledOn.Tostring()}} -First 1

The script starts with a list of computers – for a longer list I would use a text file read by get-content.

This is piped into get-hotfix where we use the computer name parameter to pull the data from the machine of interest.

Where-Object is used to filter those results that have the InstalledOn date defined.  Then we sort on the date in a descending manner – latest first. A final select pulls off the machine name (CSname) and the last installed date.

On slight drawback to this is that the date is presented as MM\DD\YYYYY.  This becomes confusing for us folks that use DD\MM\YYYY.  To make it understandable by everyone I’ve converted the date format so the month is spelled out.  What is reported as 02/10/2010 becomes 10 February 2010.


Technorati Tags: ,,
under: PowerShell and WMI, PowerShellV2


  1. By: Branko on October 23, 2011 at 1:51 pm      

    How do i filer or mark host that can’t be reached and export this to csv?

  2. By: RichardSiddaway on October 31, 2011 at 2:45 pm      

    See this post