Windows PowerShell: Detect Set-Alias/New-Alias Usage in Script Block Logging
Alerts on PowerShell scripts that create aliases via Set-Alias/New-Alias, a common obfuscation technique, using ScriptBlockText logging.
- Product
- windows
- Category
- ps_script
- Author
- frack113 (SigmaHQ), DRL 1.1
- Published
- 2023-01-08
- Updated
- 2026-09-24
ATT&CK techniques
Execution → Defense EvasionRecon
Resource Dev
Initial Access
Execution
Persistence
Priv Esc
Defense Evasion
Cred Access
Discovery
Lateral Movement
Collection
C2
Exfiltration
Impact
What it detects
This rule flags PowerShell script content that contains Set-Alias or New-Alias, which attackers can use to obscure command intent by creating alternate command names. It relies on Script Block Logging telemetry, matching on ScriptBlockText strings to identify alias creation activity and excluding specific known benign alias mappings. The detection is intended to surface potentially stealthy PowerShell execution patterns.
Reporting behind it
Changelog
v4- v4Candidate ingested via manual entry.2026-09-24
- v2Candidate ingested via manual entry.2026-07-31
- v1No 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.
title: "Windows PowerShell: Detect Set-Alias/New-Alias Usage in Script Block Logging"
id: 1d3f833a-a48b-4fc5-aa76-728498df1000
related:
- id: e8314f79-564d-4f79-bc13-fbc0bf2660d8
type: derived
- id: 96cd126d-f970-49c4-848a-da3a09f55c55
type: derived
status: test
description: This rule flags PowerShell script content that contains Set-Alias or New-Alias, which attackers can use to obscure command intent by creating alternate command names. It relies on Script Block Logging telemetry, matching on ScriptBlockText strings to identify alias creation activity and excluding specific known benign alias mappings. The detection is intended to surface potentially stealthy PowerShell execution patterns.
references:
- https://github.com/1337Rin/Swag-PSO
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/powershell/powershell_script/posh_ps_susp_set_alias.yml
author: frack113, Huntrule Team
date: 2023-01-08
modified: 2026-09-17
tags:
- attack.execution
- attack.stealth
- attack.t1027
- attack.t1059.001
logsource:
product: windows
category: ps_script
definition: "Requirements: Script Block Logging must be enabled"
detection:
selection:
ScriptBlockText|contains:
- "Set-Alias "
- "New-Alias "
filter_main_cim:
ScriptBlockText:
- Set-Alias -Name ncms -Value New-CimSession -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name gcls -Value Get-CimClass -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name ncso -Value New-CimSessionOption -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name gcms -Value Get-CimSession -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name rcms -Value Remove-cimSession -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name rcie -Value Register-CimIndicationEvent -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name gcai -Value Get-CimAssociatedInstance -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name gcim -Value Get-CimInstance -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name scim -Value Set-CimInstance -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name ncim -Value New-CimInstance -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name ncim -Value New-CimInstance -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name rcim -Value Remove-cimInstance -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
- Set-Alias -Name icim -Value Invoke-CimMethod -Option ReadOnly, AllScope -ErrorAction SilentlyContinue
condition: selection and not 1 of filter_main_*
falsepositives:
- Unknown
level: low
license: DRL-1.1