Question

I'm looking to get Windows Hotfix information from 2003 servers. For this im using the following PowerShell script as Get-Hotfix does not return all the installed dates. What I would like to do is get only updates applied after a certain date. How could this be done?

    $computername = "Compter01"
    $HotFix = Get-WmiObject win32_ntlogevent -filter "(logfile='system') AND (sourcename='ntservicepack')" -cn $computername |
    select @{name="ServerName"; e={$_.__Server}},Message,@{label="Date Installed"; expression={$_.ConverttoDateTime($_.TimeWritten)}}
Was it helpful?

Solution

Try this:

$date = [datetime]'1/1/2013'
$computername = "Compter01"
$HotFix = Get-WmiObject win32_ntlogevent -filter "(logfile='system') AND (sourcename='ntservicepack')" -cn $computername | 
    Where {$_.ConvertToDateTime($_.TimeWritten) -gt $date} | 
    Select @{name="ServerName"; e={$_.__Server}},Message,@{label="Date Installed"; expression={$_.ConverttoDateTime($_.TimeWritten)}}

There may be a way to filter out dates using the WMI filter query but that's not my area of expertise.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top