Last Hotfix Install date

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.

001
002
003
004
005
006
007
".", "rslaptop01", "127.0.0.1" | 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: ,,

2 Responses to Last Hotfix Install date

Leave a Reply