HansB
HansB

Reputation: 41

Powershell Get-WinEvent Xpath Query not valid

I would know what's wrong in my query ?

Get-WinEvent -LogName 'Application' -FilterXPath "/Event/System/Provider[@Name = 'My App']"

Each time I get the exception below:

*Get-WinEvent : La requête spécifiée n’est pas valide
Au caractère Ligne:1 : 1
+ Get-WinEvent -LogName 'Application' -FilterXPath "/Event/System/Provider[@Name = ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-WinEvent], EventLogException
    + FullyQualifiedErrorId : System.Diagnostics.Eventing.Reader.EventLogException,Microsoft.PowerShell.Commands.GetWinEventCommand*

Below the XML code of an event

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
    <Provider Name="My App" /> 
    <EventID Qualifiers="49152">24</EventID> 
    <Level>2</Level> 
    <Task>0</Task> 
    <Keywords>0x80000000000000</Keywords> 
    <TimeCreated SystemTime="2017-10-12T08:43:57.000000000Z" /> 
    <EventRecordID>37160382</EventRecordID> 
    <Channel>Application</Channel> 
    <Computer>Apps.Server</Computer> 
    <Security /> 
</System>
<EventData>
    <Data>Some additional data</Data> 

Many thanks in advance Regards

Upvotes: 0

Views: 799

Answers (1)

Vincent K
Vincent K

Reputation: 1346

Remove '/' before Event

Get-WinEvent -LogName 'Application' -FilterXPath "Event/System/Provider[@Name = 'My App']"

Get-WinEvent -LogName 'Application' -FilterXPath "Event/EventData/Data = '6.3.9600.18376'"

Upvotes: 1

Related Questions