Parameter is incorrect -FilterHashTable

This may have been asked/answered before, but I could not locate it in the search option.

I have a simple “Event Log” script that works in Server 2008 R2, but not Server 2008. Both Servers have default PS installations (V2):

$yesterday = (Get-Date) - (New-TimeSpan -Day 1)
Get-WinEvent -FilterHashTable @{LogName=‘System’; Level=2,3; StartTime=$yesterday}

Error in Server 2008 (non R2):

Get-WinEvent : The parameter is incorrect
At line:2 char:13

  • Get-WinEvent <<<< -FilterHashTable @{LogName='System'; Level=2,3; StartTime=$yesterday}
    • CategoryInfo : NotSpecified: (:slight_smile: [Get-WinEvent], EventLogException
    • FullyQualifiedErrorId : System.Diagnostics.Eventing.Reader.EventLogException,Microsoft.PowerShell.Commands.GetWinEventCommand

I assume this could be solved with an upgrade to a newer version of PS, but was curious of various (if any) solutions.

Stephen C

Looks like it may be a bug in that version of the OS (or some incompatibility with that cmdlet, at any rate, which changed as of 2008 R2). Found this article for the exact same problem description: Get-WinEvent -FilterHashtable on Windows 2008 x64

Unfortunately the link to the Connect bug from that thread doesn’t work anymore, and I haven’t been able to find more details anywhere else.