3

This work for me:

Get-WinEvent -FilterHashTable @{Logname = "ForwardedEvents" ; ID = 4625,4740}

(.... results I expect...)

This works:

$EventId = "4625"

Get-WinEvent -FilterHashTable @{Logname = "ForwardedEvents" ; ID = $EventId}

This doesn't work:

$EventId = "4625,4740"

Get-WinEvent -FilterHashTable @{Logname = "ForwardedEvents" ; ID = $EventId}

Error...

  Get-WinEvent : No events were found that match the specified selection criteria.
At line:1 char:13
+ Get-WinEvent <<<<  -FilterHashTable @{Logname = "ForwardedEvents" ; ID = $EventIds}
+ CategoryInfo          : ObjectNotFound: (:) [Get-WinEvent], Exception
+ FullyQualifiedErrorId : NoMatchingEventsFound,Microsoft.PowerShell.Commands.GetWinEventCommand

Can anyone help please?

1 Answer 1

7

Just change it to $EventId = 4625,4740 (remove the quotes) and that should work. Looking at the documentation for Get-WinEvent and the -FilterHashTable we see:

-- ID=<Int32[]>

So it is expecting an array and not a string.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Matt. Works great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.