With Windows PowerShell 5.1 left at its defaults, the event log keeps a partial record at best. The engine writes a script block to event 4104 only when its content matches patterns common in malicious scripts. Microsoft's PowerShell team described this automatic logging in a 2015 blog post as a record of last resort, not a replacement for antivirus or full script block logging. Beyond a record that the engine started, anything an intruder manages to make look ordinary leaves almost no trace there.
The other change came in August 2025, when Microsoft began removing PowerShell 2.0 from Windows 11 24H2, followed by Windows Server 2025 in September. The old engine predates script block logging, and for years it gave attackers a way to run code with very little trace. The removal closes the route on those releases, unless someone reinstalls the engine from the package Microsoft offers as a last-resort temporary mitigation. Everywhere else in the estate it stays open until someone shuts it.
The guide is aimed at systems administrators and SOC analysts in mid-sized organisations running Active Directory or Intune, with an EDR in place and a SIEM collecting events. Policy names, registry values and table schemas were checked against Microsoft Learn and MITRE ATT&CK on 23 November 2026.
The best-known references are sound but ageing. The joint information sheet from the NSA, CISA and the New Zealand and UK national cyber centres appeared in June 2022, and the Australian Signals Directorate guidance was last revised in October 2021. Neither could cover the removal of PowerShell 2.0, nor the 2026 reshuffle of ATT&CK that created the Defense Impairment tactic and moved the downgrade and log-tampering techniques into it.
What does PowerShell log, and under which event ID?
PowerShell has several logging mechanisms, each capturing something different. Mixing them up tends to mean enabling the noisiest mechanism and leaving out the most informative.
Script block logging: event 4104
Once the policy is on, Windows PowerShell 5.1 writes every script block it compiles to the Microsoft-Windows-PowerShell/Operational log as event 4104, according to the about_Logging documentation. Its value comes from where it is generated: inside the engine, at compile time. The same PowerShell team explains that code a block generates dynamically is logged as well, which exposes layers decoded at run time, such as the content of commands passed through -EncodedCommand. It has limits, though. Obfuscation within a single block, such as strings split up and reassembled at run time, is logged as written, and output from the executed code is not recorded at all.
Long scripts are split across several events. The Sigma log source guide lists the MessageNumber, MessageTotal and ScriptBlockId fields, which let the SIEM stitch fragments sharing an identifier back into the full block. A search string may straddle two fragments, which matters when writing content rules.
Module logging: event 4103
Module logging records how the pipeline runs for whichever modules are named, producing event 4103 in the Operational log and event 800 in the classic Windows PowerShell log. In our assessment it is less useful than 4104 for investigations, since it describes pipeline execution, not the full script block. Set it to every module with the * wildcard and the volume climbs quickly.
Transcription
Transcription writes the console session to text files, covering both what is typed and what comes back. By default the files land in each user's Documents folder, as the Group Policy settings reference explains. The limitation matters: it records only what appears on the console, so the body of a script launched from a file never reaches the transcript, only whatever that script displays.
PowerShell 7 is a separate program
PowerShell 7 (pwsh.exe) ignores Windows PowerShell policy unless configured to inherit it. It logs to PowerShellCore/Operational and ships its own administrative templates under Administrative Templates > PowerShell Core, installed on the local machine with the InstallPSCorePolicyDefinitions.ps1 script. In a domain, its ADMX and ADML files are copied to the central policy store. The Windows logging documentation adds a further step: the event manifest must be registered by running $PSHOME\RegisterManifest.ps1 from an elevated prompt, and again after every upgrade. Where administrators have installed PowerShell 7 themselves, that log should be checked, as it may well be empty.
Which combination suits which machines?
Guidance from 2021 and 2022 recommends enabling all three mechanisms across the board. As a goal it is sensible. For a mid-sized organisation whose SIEM bills by volume, though, the practical approach is to decide by machine class, and the table below sets out the split we use.
| Mechanism | What it captures | Cost and risk | Where to deploy |
|---|---|---|---|
| Script block logging (4104) | Every compiled block, including decoded layers | Moderate volume; may store secrets embedded in scripts | Every Windows machine, without exception |
| Invocation logging (4105 and 4106) | Start and stop of each block | High noise for little extra context | Nowhere, except during a specific investigation |
| Module logging (4103 and 800) | Per-module pipeline detail | Heavy with the wildcard; less useful than 4104 for investigations | Tier 0 servers and administration hosts |
| Transcription | Console input and output as text | Files that may contain credentials and need protecting | Administration servers, jump hosts and privileged access workstations |
| Protected Event Logging | Encrypts event content | The SIEM cannot search the text until it is decrypted | Where logs leave a trusted boundary |
| Removing PowerShell 2.0 | Closes the route to run without script block logging | May break legacy software that requests version 2 | The whole estate, once dependencies are inventoried |
| Constrained Language Mode | Restricts what unapproved scripts can do | Holds up against bypass only with App Control in system lockdown | User workstations without administrative duties |
Hard2bit's assessment, based on Microsoft Learn documentation and the Microsoft PowerShell team blog. The allocation by machine class is indicative and should follow each organisation's tiering model.
Script block logging is the only control we recommend without qualification. It gives an analyst most of what is needed to reconstruct an incident, at a volume that is usually manageable. Module logging and transcription earn their cost where risk concentrates, on the machines used to administer the domain, in line with a privileged access tiering model.
Deployment: exact values and how to verify them
Group Policy and registry values
For Windows PowerShell, the three policies sit under Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell. They are named Turn on PowerShell Script Block Logging, Turn on Module Logging and Turn on PowerShell Transcription, and each one writes beneath HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell:
- Script blocks: subkey
ScriptBlockLogging, valueEnableScriptBlockLoggingset to 1. The invocation logging tick box writesEnableScriptBlockInvocationLogging, which we advise leaving clear. - Modules: subkey
ModuleLogging, valueEnableModuleLoggingset to 1, plus aModuleNamessubkey listing the modules of interest, or a*entry if the volume is acceptable. - Transcription: subkey
Transcription, withEnableTranscriptingset to 1,OutputDirectorypointing at a network path andEnableInvocationHeaderset to 1 so that each command carries a timestamp.
One detail has consequences. Microsoft's PowerShell team states in the same 2015 blog post that automatic logging of suspicious blocks is switched off by setting the policy to Disabled, which writes 0. A machine configured that way is worse off than one where the policy was never configured.
For PowerShell 7 the equivalent path is HKLM\SOFTWARE\Policies\Microsoft\PowerShellCore. The PowerShell Core logging, transcription and execution policies include the option Use Windows PowerShell Policy setting, which makes pwsh.exe inherit the Windows PowerShell configuration and avoids maintaining two sets of values. The same policies also exist under User Configuration, so any review should cover both scopes.
Intune and other device management tools
On Intune-managed devices, the Policy CSP, in its WindowsPowerShell area, exposes TurnOnPowerShellScriptBlockLogging at the OMA-URI ./Device/Vendor/MSFT/Policy/Config/WindowsPowerShell/TurnOnPowerShellScriptBlockLogging. It is ADMX-backed and takes a string payload. Transcription and module logging can be delivered through the Settings Catalog or a script that writes the registry values above.
Checking on the endpoint
A linked Group Policy Object is no proof that a machine has applied it. The read-only checks below, run from an elevated prompt, show which settings are in force. A missing registry path means the policy has not been applied in that scope, and the same paths under HKCU cover user policies:
# Applied policy values for Windows PowerShell.
Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging'
Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging'
Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription'
# The same for PowerShell 7 and its event log.
Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\PowerShellCore\ScriptBlockLogging'
Get-WinEvent -ListLog PowerShellCore/Operational
# Maximum size and state of the Operational log.
wevtutil gl Microsoft-Windows-PowerShell/Operational
# PowerShell 2.0 state on a Windows client.
Get-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root
# Language mode of the current session.
$ExecutionContext.SessionState.LanguageMode
# Which Group Policy Object wins on this machine, user policies included.
gpresult /h gpo-report.html /f
The policy achieves little if the Operational log is small. If it fills before the SIEM agent has collected the events, the oldest are overwritten. On heavily automated servers, it can be enlarged from an elevated prompt with wevtutil sl Microsoft-Windows-PowerShell/Operational /ms:1073741824 (1 GB). The size is given in bytes and Windows rounds it to multiples of 64 KB; the figure should be revisited after a week in service.
A transcript folder users cannot read back
Leaving transcripts in Documents causes two problems. Anyone using that session can delete them, and if the folder is redirected to OneDrive they end up synchronised to the cloud. Transcripts are written by the PowerShell process under the identity of the user who opened the session, so permissions have to be designed around users, not computer accounts.
In 2015 Microsoft's PowerShell team published a permission model for that share. It removes inheritance, grants full control to Administrators and write and read-attributes to Everyone, and adds an inherited deny-all entry for Creator Owner. Each user can therefore create a transcript but cannot read it again or list anyone else's, while the share itself grants Change to Everyone. We add one adjustment: reading is limited to a restricted security team group, and administration of the folder stays with a controlled account.
The contents should be treated as sensitive, because a transcript captures any password typed in clear text. Testing should also cover laptops working away from the corporate network.
Protected Event Logging
The Enable Protected Event Logging policy, under Windows Components > Event Logging, uses the CMS standard to encrypt event content from participating applications such as PowerShell. Microsoft requires a certificate carrying the Document Encryption EKU (1.3.6.1.4.1.311.80.1) together with Data Encipherment or Key Encipherment usage and warns that the private key must not be deployed to the machines doing the logging. It also recommends enabling it whenever script block logging is used for anything beyond diagnostics, given the secrets it can hold.
We depart from that advice for an operational reason. With content encrypted, the content rules and the validation step described below stop working unless the collector first decrypts with Unprotect-CmsMessage. We keep it for cases where logs travel to a third party or to storage less protected than the endpoint, and elsewhere compensate by tightly restricting who can read those events in the SIEM.
Removing PowerShell 2.0 where Microsoft has not yet done so
According to Microsoft's support notice, on updated Windows 11 24H2 and Windows Server 2025 machines a request for version 2 now starts PowerShell 5.1. On Windows 10, on out-of-support Windows 11 23H2 or earlier, and on servers before Windows Server 2025 the feature remains. It can be removed from an elevated prompt with Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root -NoRestart on clients or Uninstall-WindowsFeature PowerShell-V2 on servers. The same notice points out that server products such as Exchange, SharePoint and SQL relied on PowerShell 2.0 in older versions, while current releases use modern PowerShell. Before removing it, any software from that generation still in service needs to be inventoried.
Constrained Language Mode backed by application control
Constrained Language Mode limits the types and calls available to unapproved scripts. According to about_Language_Modes, PowerShell applies it automatically when it detects an App Control for Business or AppLocker policy, and it only holds up against bypass when App Control enforces system lockdown. Setting it from inside the session is fine for experiments and of no use as a control.
Getting events into the SIEM, and what it costs
With Azure Monitor Agent, channels other than Security are collected through a data collection rule using XPath queries in the form LogName!XPathQuery, as the Azure Monitor documentation explains. The same page states that these events land in the Event table and that the XPath filter does not support contains or starts-with, so filtering on content happens later, in the query. Three expressions cover this guide, and each should be tested first on a machine with Get-WinEvent -LogName <log> -FilterXPath <query>, separating the log name from the part after the exclamation mark:
- PowerShell 5.1:
Microsoft-Windows-PowerShell/Operational!*[System[(EventID=4103 or EventID=4104)]]. - PowerShell 7:
PowerShellCore/Operational!*[System[(EventID=4103 or EventID=4104)]]. - The classic log, for event 400, which records the engine version at start-up, and module event 800:
Windows PowerShell!*[System[(EventID=400 or EventID=800)]].
Microsoft Defender for Endpoint adds process and registry change telemetry, which two of the detections below rely on, and AMSI lets it inspect script content at run time. The EDR's visibility complements event 4104 without replacing it. The event stays in the SIEM for whatever retention period the organisation sets, and it is evidence a forensic investigator or an auditor can consult without depending on the vendor. If the question is which sources to prioritise on a tight budget, our guide to which logs to send to the SIEM covers the rest.
Volume should be measured before collection is switched on across the estate. The _BilledSize column shows what each machine costs over a one-week pilot:
// Billed volume per machine for PowerShell events over the last 7 days.
Event
| where TimeGenerated > ago(7d)
| where EventLog in ("Microsoft-Windows-PowerShell/Operational", "PowerShellCore/Operational", "Windows PowerShell")
| summarize Events = count(), MB = round(sum(_BilledSize) / 1048576.0, 1) by Computer, EventLog, EventID
| order by MB desc
Detection: annotated queries and their false positives
The queries that follow target PowerShell abuse and, above all, attempts to switch logging off. Those using the Event table are written for Microsoft Sentinel; those using Device* tables are for advanced hunting in Defender XDR. Each one is mapped to the relevant MITRE ATT&CK technique in the current version of the framework. Before any of them is promoted to a rule, Event | distinct EventLog should be run in the workspace to confirm the log names arrive as written, and the block text should appear in full in RenderedDescription; if it does not, ScriptBlockText can be extracted from EventData.
Script blocks showing AMSI tampering or in-memory loading
// T1059.001 and T1685 (Disable or Modify Tools): 4104 blocks with signs of AMSI evasion or in-memory code loading.
Event
| where TimeGenerated > ago(1h)
| where EventLog in ("Microsoft-Windows-PowerShell/Operational", "PowerShellCore/Operational") and EventID == 4104
| where RenderedDescription has_any ("AmsiUtils", "amsiInitFailed", "Reflection.Assembly", "FromBase64String", "DownloadString")
// Exclude legitimate automation that uses these functions here, by script path or by host.
| project TimeGenerated, Computer, UserName, EventLog, RenderedDescription
The first two strings have very few legitimate uses and justify an alert on their own. The other three turn up in deployment scripts, third-party agents and inventory tools. We suggest building an exclusion list over two or three weeks and raising severity only when host and time line up with an unusual parent process in DeviceProcessEvents, such as an Office application or a browser. Its misses are the ones already described: obfuscation inside a block and strings split across fragments.
Machines that stop sending 4104 events
// T1685.001: hosts that sent 4104 in the past week, are still alive and have sent none for 24 hours.
// Lower-case short names are compared, because Event and Heartbeat may or may not include the domain.
let short = (c: string) { tolower(tostring(split(c, ".")[0])) };
let alive = Heartbeat
| where TimeGenerated > ago(1h)
| summarize LastHeartbeat = max(TimeGenerated) by Host = short(Computer);
Event
| where TimeGenerated > ago(8d) and EventID == 4104
| where EventLog in ("Microsoft-Windows-PowerShell/Operational", "PowerShellCore/Operational")
| summarize Last4104 = max(TimeGenerated) by Host = short(Computer)
| where Last4104 < ago(1d)
| join kind=inner (alive) on Host
| project Host, Last4104, LastHeartbeat
The query watches the sensor, catching host-wide tampering and misconfiguration alike. It cannot see evasion confined to one session while other processes keep logging, and if the intruder stops the collection agent the host drops out of Heartbeat too, so it needs a companion rule for lost heartbeats. Typical false positives are a server with no scheduled PowerShell work that goes a day without running anything, and machines returning from being switched off or from a maintenance window. In many estates, management agents call PowerShell daily, which keeps that noise down.
Registry changes that switch PowerShell logging off
// T1685.001 and T1112: PowerShell 5.1 or 7 logging values set to 0 or deleted.
DeviceRegistryEvents
| where Timestamp > ago(1d)
// On deletions, the path may arrive in PreviousRegistryKey.
| extend Key = iff(ActionType endswith "Deleted", coalesce(PreviousRegistryKey, RegistryKey), RegistryKey)
// No trailing backslash, so the parent key is included.
| where Key matches regex @"(?i)\\Policies\\Microsoft\\(Windows\\PowerShell|PowerShellCore)(\\|$)"
// Deletions, values set to 0 and changes to the transcript folder.
| where ActionType endswith "Deleted"
or (RegistryValueName in~ ("EnableScriptBlockLogging", "EnableModuleLogging", "EnableTranscripting", "EnableInvocationHeader") and RegistryValueData in ("0", "0x00000000"))
or (RegistryValueName =~ "OutputDirectory" and RegistryValueData != PreviousRegistryValueData)
| project Timestamp, DeviceName, ActionType, Key, RegistryValueName, PreviousRegistryValueName, RegistryValueData, PreviousRegistryValueData, InitiatingProcessFileName, InitiatingProcessCommandLine
SigmaHQ maintains a related high-severity rule that covers these values being set to 0, though not deletions. It is written for the Sysmon format and does not work unchanged in Defender. The Group Policy service and the Intune agent may rewrite these values while processing policy, so their processes have to be identified and excluded. A change made by a console, a script or a remote access tool calls for immediate investigation. Microsoft's hunting queries compare DWORD data in decimal; ours also accepts the hexadecimal form, and a test change in the tenant confirms it.
Attempts to start or reinstate the PowerShell 2.0 engine
ATT&CK now lists the downgrade as T1689, Downgrade Attack, under the Defense Impairment tactic, and the old T1562.010 redirects there. The entry specifically mentions running an older PowerShell version that lacks script block logging. Rules still tagged T1562.010 are due an update; rules on disabling logs now belong under T1685.001, Disable or Modify Windows Event Log.
In 2017 Lee Holmes, then on Microsoft's PowerShell team, showed how to detect the downgrade through event 400 in the classic Windows PowerShell log, which records the engine version; the third XPath expression above collects it. Over EDR telemetry, the KQL looks like this:
// T1689: a request for engine 2.0, or an attempt to re-enable the feature.
DeviceProcessEvents
| where Timestamp > ago(1d)
| where
// Engine 2.0 requested by parameter; the original file name catches renamed copies.
((FileName =~ "powershell.exe" or ProcessVersionInfoOriginalFileName =~ "PowerShell.EXE")
and ProcessCommandLine matches regex @"(?i)\s[-/\x{2013}\x{2014}\x{2015}]v(e(r(s(i(o(n)?)?)?)?)?)?[\s:]+2(\.0)?(\s|$)")
// Re-enabling the optional feature on clients, through PowerShell or DISM.
or (ProcessCommandLine has_any ("MicrosoftWindowsPowerShellV2Root", "MicrosoftWindowsPowerShellV2")
and ProcessCommandLine matches regex @"(?i)enable-(windowsoptional)?feature")
// Reinstating the feature on servers.
or ProcessCommandLine matches regex @"(?i)(install|add)-windowsfeature\b.*powershell-v2"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName
For Sigma, the starting point is the SigmaHQ rule for this case, rated medium. It looks for abbreviations of the -Version parameter followed by 2 on the powershell.exe command line, with plain dashes only. The compact version below adds the windash modifier to cover other dash variants, checks the original file name and uses the new ATT&CK tags. It is written entirely in YAML flow style, which does not depend on indentation:
title: PowerShell started requesting engine 2.0
id: 227b3eb5-6266-411c-85b4-4cb424403b85
related: [{id: b3512211-c67e-4707-bedc-66efc7848863, type: derived}]
status: experimental
description: 'Detects powershell.exe started with the version 2 parameter, used to evade script block logging.'
author: Hard2bit
date: 2026-11-23
tags: [attack.defense-impairment, attack.t1689]
logsource: {product: windows, category: process_creation}
detection: {sel_img: {'Image|endswith': '\powershell.exe'}, sel_orig: {OriginalFileName: 'PowerShell.EXE'}, sel_cli: {'CommandLine|windash|contains': [' -version 2', ' -versio 2', ' -versi 2', ' -vers 2', ' -ver 2', ' -ve 2', ' -v 2']}, condition: '(sel_img or sel_orig) and sel_cli'}
falsepositives: ['Legacy software that still declares a PowerShell 2.0 dependency']
level: high
Both rules have known gaps. They miss the old engine being loaded by a process other than powershell.exe, which Holmes suggested covering by auditing or blocking loads of the 2.0 engine's assemblies. The KQL, for its part, may fire when a script takes a parameter of its own called -v. On remediated machines the request has no effect, yet it remains a signal of interest.
The second and third conditions fire only on enabling commands passed on the command line (Enable-WindowsOptionalFeature, DISM /Enable-Feature or Install-WindowsFeature), not on audit or removal commands. Commands typed inside an interactive session spawn no new process and surface only in event 4104, so the same names should be searched for in the Event table as well. Removing the feature remains the effective control; the detection serves first as an inventory of who is still asking for it.
Validating the detections
To confirm that 4104 reaches the SIEM, a harmless command with a recognisable marker, such as Write-Output 'H2B-VALIDATION-4104', can be run on a test machine and the Event table searched for that string. The removal of PowerShell 2.0 is confirmed with Get-WindowsOptionalFeature, as shown earlier, or Get-WindowsFeature PowerShell-V2 on servers.
Starting powershell.exe with -Version 2 will trip the rule above and very likely the EDR, so it should be done only on a test machine, with the SOC told beforehand. Content rules are best validated in a lab, either by replaying a sample event or with harmless in-house test scripts that reproduce the strings the rule looks for, based on the procedures listed under T1059.001, always with the SOC lead's written authorisation.
Common mistakes and the limits of logging
Script block logging can store secrets. Microsoft's documentation says so plainly: if a script contains a hard-coded password, so does the event. Before enabling it, the organisation has to decide who can read those events in the SIEM and review automation scripts that embed credentials, which are a problem with or without logging.
Nor does it cover every form of abuse. An intruder with administrative rights can change the policies, clear the log or run .NET code without touching PowerShell at all. For that reason the silence and registry queries carry as much weight as the content rules. Detecting abuse of trusted binaries, covered in our guide to LOLBins, closes part of that gap.
Two further mistakes come up repeatedly: assuming PowerShell 7 is covered because Windows PowerShell is already logging, and setting the policy to Disabled in the belief that it means the same as leaving it unconfigured. Both leave a machine with less visibility than its owner believes.
Finally, Constrained Language Mode breaks scripts that rely on disallowed .NET types. It should be trialled first with App Control in audit mode and rolled out in phases, starting with user workstations that carry no administrative role.
Evidence for ENS, ISO 27001 and NIS2 audits
The configuration described here produces verifiable evidence for several frameworks. For organisations subject to Spain's Esquema Nacional de Seguridad (Royal Decree 311/2022, Annex II), the public sector security framework that also binds its suppliers, it addresses op.exp.8 (activity logging), supports op.mon.3 (monitoring) and, for the policies themselves, op.exp.3 (security configuration management). In ISO/IEC 27001:2022 it maps to controls A.8.15 (logging), A.8.16 (monitoring activities) and A.8.9 (configuration management). For NIS2, Article 21(2)(b) of Directive (EU) 2022/2555 requires incident handling measures that are hard to substantiate without endpoint activity logs.
The output of the checks above, the SIEM collection rule and a record for each detection make up the evidence pack an auditor will typically expect. For financial entities subject to DORA, Article 12 of Delegated Regulation (EU) 2024/1774 also requires logging procedures, protocols and tools, and this configuration helps meet it. If this work is part of an ENS compliance programme, our ENS compliance service covers it.
Where to start with limited capacity
If there is room for only one measure, it should be this: script block logging enabled on every Windows machine, for both Windows PowerShell and PowerShell 7, with confirmation that 4104 reaches the SIEM. Few measures offer as much forensic value for the effort, and its absence is what we most often run into when called in to investigate an incident. Next come removing PowerShell 2.0 from the machines Microsoft has not yet dealt with and deploying the rule that fires when a host stops sending events.
With that telemetry in place, a managed SOC or a threat hunting engagement has something to work with from the outset. Without it, reconstructing PowerShell activity rests almost entirely on whatever the EDR happened to keep.
Sources and methodology: policies, registry values, events and tables come from Microsoft Learn documentation on PowerShell, Intune, Azure Monitor and Defender XDR. The removal of PowerShell 2.0 rests on Microsoft's support notice, and automatic logging and the transcript share on the Microsoft PowerShell team blog. Techniques were checked against MITRE ATT&CK, rules against the SigmaHQ repository, and recommendations against the NSA and CISA information sheet (2022) and the ASD guidance (2021). Regulatory references come from the BOE, EUR-Lex and ISO/IEC 27001:2022. Information verified on 23 November 2026.
Disclaimer: this guide is for guidance only and does not replace an assessment of each environment. Microsoft products, the ATT&CK framework and public rule sets change frequently, so policies, commands and queries should be validated in a test environment before they reach production. Tests that simulate attack techniques require prior written authorisation from the system owner.
Frequently asked questions
What is the difference between PowerShell events 4103 and 4104?
▾
Event 4104 comes from script block logging and records each block as the engine compiles it, including layers decoded during execution, which makes it the most useful for investigations. Event 4103 comes from module logging and describes pipeline execution for the chosen modules. It generates more volume and, in our assessment, is less useful for investigations because it does not record the full script block.
Is an EDR enough to see what runs through PowerShell?
▾
One does not replace the other. The EDR inspects scripts through AMSI and can block during execution. Event 4104 makes it possible to correlate PowerShell activity with sign-ins, email or network data in the SIEM, and keep it for as long as internal policy or a regulator requires, independently of the vendor contract.
Does script block logging slow machines down?
▾
On user workstations the impact is normally unnoticeable. The cost lies in the events shipped to the SIEM, particularly from heavily automated servers. We therefore suggest measuring volume per machine over a one-week pilot before a wider rollout, and enlarging the Operational log where needed.
Does PowerShell 7 follow the same policies as Windows PowerShell?
▾
Not by default. PowerShell 7 has its own administrative templates under PowerShell Core and logs to PowerShellCore/Operational. The logging and transcription policies offer an option to inherit the Windows PowerShell setting, and the event manifest must be registered with RegisterManifest.ps1 after installing or upgrading.
What happens to scripts that request PowerShell 2.0 on Windows 11 24H2?
▾
Microsoft says that on releases without PowerShell 2.0, a request for that version starts PowerShell 5.1 instead, and it expects failures only in rare cases, such as scripts that rely on behaviour specific to version 2. Microsoft's guidance is to migrate to PowerShell 5.1 or 7.
Can PowerShell transcripts contain passwords?
▾
Yes. A transcript makes no distinction between a command and a password typed at the console; it keeps both. Transcription is therefore best restricted to servers and administration hosts, with the share treated as a store of sensitive data, with tightly limited read access and a defined retention period.
How can disabled PowerShell logging be detected on a machine?
▾
Two signs give it away: whether PowerShell policy values have been set to 0 or removed from the registry, and whether a machine that is still switched on and sending heartbeats has stopped producing 4104 events. The queries in the guide cover both; when the heartbeat has gone as well, the investigation starts with the collection agent.