query Windows Event Log from scripts using Get-WinEvent -FilterXPath and equivalent wevtutil query-events XPath filters

domain: learn.microsoft.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Build a simple XPath filter and query the System log with `Get-WinEvent -LogName System -FilterXPath "*[System[(EventID=7036)]]"`.
  2. Combine multiple conditions (event ID and time range) inside a single `System[...]` predicate using and/or, since Windows Event Log only supports a constrained subset of XPath 1.0.
  3. Run the equivalent filter from the command line without PowerShell using `wevtutil qe System "/q:*[System[(EventID=7036)]]" /f:text`.
  4. When a compound expression exceeds roughly 20 sub-expressions or spans multiple event sources, switch to a structured XML query (-FilterXml) instead of a larger XPath string.
  5. Test the XPath filter interactively in Event Viewer's Filter Current Log > XML tab > Edit query manually before embedding it in a script.

Known gotchas

Related routes

Query live system information on Windows using CIM cmdlets (Get-CimInstance) and WQL filters
learn.microsoft.com · 5 steps · unrated
Retrieve and process HubSpot custom behavioral event completions in bulk using the Events API v3, filtering by event type and date range
hubspot.com · 5 steps · unrated
Query logs for Render services/databases via API (GET /v1/logs) with filters and pagination
render.com · 3 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans