Windows PowerShell: Add-Content to $profile for Potential Persistence

Detects PowerShell Add-Content writing to $profile, especially when paired with common command-loading or execution payloads.

FreeReviewedSigma · Medium · v2
Product
windows
Category
ps_script
Author
frack113, Nasreddine Bencherchali (Nextron Systems) (SigmaHQ), DRL 1.1
Published
2021-08-18
Updated
2026-07-31

ATT&CK techniques

Persistence → Priv Esc
  1. Recon

  2. Resource Dev

  3. Initial Access

  4. Execution

  5. Defense Evasion

  6. Cred Access

  7. Discovery

  8. Lateral Movement

  9. Collection

  10. C2

  11. Exfiltration

  12. Impact

What it detects

This rule flags PowerShell script block activity containing 'Add-Content $profile', indicating an attempt to write content into the current user’s PowerShell profile. It matters because modifying $profile can introduce attacker-controlled commands that execute automatically in future PowerShell sessions. The detection relies on ScriptBlockText telemetry (with Script Block Logging enabled) and matches when the script writes profile content and includes suspicious command strings such as Invoke-Expression, IEX, Invoke-WebRequest, or Start-Process.

Related detections3 linkedT1546.013 — drag to rearrange
Suspicious Creation of PowerShell Profile Script for Persistence
Windows File Changes to Microsoft.VSCode_profile.ps1 via PowerShell Profile
Windows PowerShell Profile File Creation or Modification
Windows PowerShell: Add-Content to $profile for Potential Persistence
Pivot detection · T1546.013 · 3 related

Changelog

v2
  1. v2
    Candidate ingested via manual entry.2026-07-31
  2. v1
    No changelog recorded for this version.2026-07-30

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.