Parameter is incorrect -FilterHashTable

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Dave Wyatt Dave Wyatt 8 months, 3 weeks ago.

  • Author
    Posts
  • #36874
    Profile photo of StephenC
    StephenC
    Participant

    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: (:) [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. Thanks, Stephen C

  • #36875
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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: https://social.technet.microsoft.com/Forums/windowsserver/en-US/fd147c9a-fb02-45dc-8c5a-b6f5a9bf7ab0/getwinevent-filterhashtable-on-windows-2008-x64?forum=winserverpowershell

    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.

You must be logged in to reply to this topic.