How to filter dates in powershell using where-object from output of win32_reliabilityRecords
<p>I am trying to create a powershell script to get the failed hotfix which are 1 or 2 days old.</p>

<p>So I am trying to select 2 day old failed patches using where-object but it is not properly throwing the correct output.</p>

<p>Below is the command that I have written with the help of google.</p>

<pre><code>$mail_body = Get-WmiObject -Class win32_reliabilityRecords -Filter "SourceName = 'Microsoft-Windows-WindowsUpdateClient'" | Select-Object user, productname, @{LABEL = “date”;EXPRESSION = {$_.ConvertToDateTime($_.timegenerated)}} | where { $_.message -match ‘failure’ } | ConvertTo-Html -Head $style 
</code></pre>