Windows Event ID · Microsoft-Windows-PowerShell/Operational log

Event ID 4104: PowerShell script block logging

Records the PowerShell code that actually runs, after Base64 and other encoding is removed. Windows logs suspicious script blocks automatically, and full logging can be turned on by policy.

Key fields

ScriptBlockText
The code that ran.
ScriptBlockId
Links the parts of a long script together.
Path
The script file, if there was one.

What looks suspicious

  • IEX with DownloadString or Invoke-WebRequest.
  • Set-MpPreference -Disable... and Add-MpPreference -ExclusionPath.
  • FromBase64String and other decoding inside the script.

Practise with real logs

These labs give you an .evtx file where Event ID 4104 is part of the story.

Related Event IDs

Questions people ask

What is Event ID 4104?

Event ID 4104 (Microsoft-Windows-PowerShell/Operational log) means "PowerShell script block logging". Records the PowerShell code that actually runs, after Base64 and other encoding is removed. Windows logs suspicious script blocks automatically, and full logging can be turned on by policy.

What should I look for in Event ID 4104?

IEX with DownloadString or Invoke-WebRequest. Set-MpPreference -Disable... and Add-MpPreference -ExclusionPath. FromBase64String and other decoding inside the script.

Full field reference: the Windows Security Log Encyclopedia and Microsoft's documentation. Back to the Event ID cheat sheet.