powershell-logging
/powershell-logging
Enable and analyze PowerShell telemetry — script block logging (4104), module logging (4103), transcription, AMSI — to detect encoded commands, download cradles, obfuscation and downgrade attacks. Use when investigating malicious PowerShell, reviewing logging configuration, or writing PowerShell detections.
- Author
- kaandgnsh ↗
- Repository
- Claude-Blue ↗
- Licence
- MIT
- Last repository change
- 01.11.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 3
No signals detected. Repository changed on 01.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Enable and analyze PowerShell telemetry — script block logging (4104), module logging (4103), transcription, AMSI — to detect encoded commands, download cradles, obfuscation and downgrade attacks. Use when investigating malicious PowerShell, reviewing logging configuration, or writing PowerShell detections.
Original author description
Enable and analyze PowerShell telemetry — script block logging (4104), module logging (4103), transcription, AMSI — to detect encoded commands, download cradles, obfuscation and downgrade attacks. Use when investigating malicious PowerShell, reviewing logging configuration, or writing PowerShell detections.
How it works
- Enable (GPO: Administrative Templates → Windows Components → Windows PowerShell)
- What to hunt in 4104/4688
- Queries
- Sigma example
- Related skills
- References
SKILL.md preview
---
name: powershell-logging
description: Enable and analyze PowerShell telemetry — script block logging (4104), module logging (4103), transcription, AMSI — to detect encoded commands, download cradles, obfuscation and downgrade attacks. Use when investigating malicious PowerShell, reviewing logging configuration, or writing PowerShell detections.
license: MIT
metadata:
category: windows-security
version: "2.0.0"
verification: documented
---
# PowerShell Logging and Analysis
## Enable (GPO: Administrative Templates → Windows Components → Windows PowerShell)
| Setting | Event | Value |
|---|---|---|
| Turn on PowerShell Script Block Logging | 4104 in `Microsoft-Windows-PowerShell/Operational` | Decoded, deobfuscated script content at execution |
| Turn on Module Logging (`*`) | 4103 | Pipeline execution details |
| Turn on PowerShell Transcription | Text files | Full session I/O; write to a protected share |
| Protected Event Logging (optional) | — | Encrypts 4104 content with a certificate |
PowerShell 5+ automatically logs "suspicious" script blocks at Warning level even without the policy. PowerShell 7 logs to `PowerShellCore/Operational`.
## What to hunt in 4104/4688
- Encoded commands: `-enc`, `-EncodedCommand`, `-e ` with long base64; decode: `[Text.Encoding]::Unicode.GetString([Convert]::FromBase64String($b64))`.
- Download cradles: `IEX`, `Invoke-Expression`, `DownloadString`, `DownloadFile`, `Net.WebClient`, `Invoke-WebRequest ... | iex`, `Start-BitsTransfer`.
- AMSI bypass strings: `AmsiUtils`, `amsiInitFailed`, `AmsiScanBuffer` patching.
- Defender tampering: `Set-MpPreference -DisableRealtimeMonitoring $true`, `Add-MpPreference -ExclusionPath`.
- Downgrade: `powershell.exe -version 2` (bypasses script block logging; remove the PowerShell v2 feature).
- Credential tools: `Invoke-Mimikatz`, `sekurlsa`, `Get-GPPPassword`, `Invoke-Kerberoast`.
- Large script blocks are split across multiple 4104 events (`MessageNumber`/`MessageTotal`, same `ScriptBlockId`) — reassemble before analysis.
## Queries
Sentinel (MDE): `DeviceProcessEvents | where FileName in~ ("powershell.exe","pwsh.exe") and ProcessCommandLine matches regex @"(?i)\s-(e|en|enc|enco|encod|encode|encoded|encodedc|encodedcommand)\s+[A-Za-z0-9+/=]{40,}"`
Splunk: `index=wineventlog source="XmlWinEventLog:Microsoft-Windows-PowerShell/Operational" EventCode=4104 (ScriptBlockText="*DownloadString*" OR ScriptBlockText="*AmsiUtils*")`
## Sigma example
```yaml
title: PowerShell Script Block With AMSI Bypass Strings
id: 2b6f0c8e-9d3f-4c55-8c0f-6f1f0a8f3b21
status: experimental
description: Detects script blocks referencing AMSI bypass primitives.
references:
- https://learn.microsoft.com/en-us/windows/win32/amsi/antimalware-scan-interface-portal
author: Claude-Blue
date: 2026-10-31
tags:
- attack.defense-impairment
- attack.t1685
logsource:
product: windows
category: ps_script
detection:
selection:
ScriptBlockText|contains:
- 'AmsiUtils'
- 'amsiInitFailed'
- 'AmsiScanBuffer'
condition: selection
falsepositives:
- Security tooling and research scripts
level: high
```
## Related skills
`script-deobfuscation`, `windows-event-log-analysis`, `sigma-authoring`, `lolbin-hunt`
## References
- Microsoft about_Logging_Windows: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logging_windows
- MITRE ATT&CK T1059.001: https://attack.mitre.org/techniques/T1059/001/
Versions
The database has no other skills named powershell-logging.
Database snapshot: 13.11.2026 · package version cf8e663ea0df (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100detecting-suspicious-powershell-execution
Hunt for suspicious PowerShell execution (T1059.001) such as encoded commands, download cradles, AMSI bypass, and constrained language mode evasion using EDR telemetry (CrowdStrike, Microsoft Defender for Endpoint), Sysmon, and SIEM queries (Splunk, Elastic). Use when… - 100threat-hunting-powershell-cmd-execution-traces
Use this skill when hunt for obfuscated PowerShell commands, encoded scripts, and command-line download cradles. - 96write-script-powershell
MUST use when writing PowerShell scripts. - 96powershell
PowerShell开发专家助手。当用户需要进行PowerShell脚本开发、Windows自动化、系统运维脚本、模块开发或跨平台管理任务时调用。 - 90powershell-security-hardening
Use this agent when you need to harden PowerShell automation, secure remoting configuration, enforce least-privilege design, or align scripts with enterprise security baselines and compliance frameworks. - 100powershell
Enterprise PowerShell coding standards. Use when writing, reviewing, or generating any PowerShell code, creating PS1 scripts or functions, debugging PowerShell, or asked to help with PowerShell. Enforces best practices for structure, error handling, security, performance, and output patterns.