Suspicious PowerShell Get Current User (via ps_script)

This rule detects the use of PowerShell to identify the current logged user.

SigmalowWindowsv1
sigma
title: Suspicious PowerShell Get Current User (via ps_script)
id: 561af587-3137-5438-8a77-baaf41dc2258
status: stable
description: This rule detects the use of PowerShell to identify the current logged user.
references:
    - https://attack.mitre.org/techniques/T1033/
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1033/T1033.md#atomic-test-4---user-discovery-with-env-vars-powershell-script
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1033/T1033.md#atomic-test-5---getcurrent-user-with-powershell-script
author: Huntrule Team
date: 2026-02-27
tags:
    - attack.discovery
    - attack.t1033
logsource:
    product: windows
    category: ps_script
    definition: 'Requirements: Script Block Logging must be enabled'
detection:
    selection:
        ScriptBlockText|contains:
            - '[System.Environment]::UserName'
            - '$env:UserName'
            - '[System.Security.Principal.WindowsIdentity]::GetCurrent()'
    condition: selection
falsepositives:
    - Unknown
level: low

Known false positives

  • Unknown

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