Get-WinEvent and filtering for the message

Welcome Forums General PowerShell Q&A Get-WinEvent and filtering for the message

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 7 months ago.

  • Author
  • #5890

    Topics: 1562
    Replies: 0
    Points: 0
    Rank: Member

    by surveyor at 2013-05-10 10:03:06

    with this little script (it works) I try to filter scheduled tasks (beginning and end) from the eventlog. Is it possible to filter for messages in the XML-Filter instead of using Where-Object? I have searched a lot, but there are only a few examples and the official documentation is too confusing for me.


    $XMLQuery = @"


    $Abruf = {
    # Wegen .NET-Bug auf englische Umgebung umschalten. Ansonsten werden keine Meldungstexte ausgegeben.
    $orgCulture = Get-Culture
    [System.Threading.Thread]::CurrentThread.CurrentCulture = New-Object "System.Globalization.CultureInfo" "en-US"

    Get-WinEvent -FilterXml $XMLQuery |
    Where-Object { $_.Message -notmatch "\\Microsoft\\" } # |
    # Select-Object -First 5

    # Wegen .NET-Bug. Siehe oben.
    [System.Threading.Thread]::CurrentThread.CurrentCulture = $orgCulture
    $a = Get-Date
    $Test = . $Abruf
    $b = Get-Date

    PS: I'm not very happy with the new forum...

The topic ‘Get-WinEvent and filtering for the message’ is closed to new replies.