Anavem
Languagefr
administrative templatesComputer ConfigurationNot configured

Turn on PowerShell Script Block Logging

Logs the full content of all PowerShell script blocks. Generates event 4104. Critical for threat detection.

10 May 20264 min
Policy path
Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
Supported on
Windows 10, Windows 11, Windows Server 2016 and later

Logs the full content of all PowerShell script blocks. Generates event 4104. Critical for threat detection. Security baselines recommend setting it to Enabled.

Description

Turn on PowerShell Script Block Logging is a Windows Group Policy setting located under Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell. It applies to the Computer Configuration branch and is classified as a Warning-level policy in the PowerShell category.

Logs the full content of all PowerShell script blocks. Generates event 4104. Critical for threat detection.

Microsoft sets the default value to Not configured while industry security baselines (CIS, NIST, DISA STIG) recommend Enabled.

Under the hood, this policy is enforced through the Windows registry at HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging using the value name EnableScriptBlockLogging. Modifying the value directly through regedit.exe or PowerShell produces the same effect as configuring the GPO, but going through Group Policy is preferred so that the setting is centrally managed and survives reboots, image rebuilds, and policy refresh cycles.

In-depth explanation

This setting has a meaningful impact on the security posture or operational stability of the system. Leaving it at the Microsoft default is acceptable for standalone or low-risk environments, but most security baselines (CIS, NIST, DISA STIG) explicitly call for hardening it before the device is exposed to untrusted users or networks.

The policy is grouped under PowerShell, which means it is typically applied through a domain-wide GPO linked at the OU level. In a multi-tenant MSP context, scope it through WMI filters or security group filtering rather than linking at the domain root, so that you can roll out progressively (pilot OU → wider rings → all production).

The setting takes effect after the next Group Policy refresh (gpupdate /force for immediate testing, or by default within ~90 minutes for workstations and ~5 minutes on domain controllers). For computer-side policies a reboot may be required; for user-side policies, a sign-off/sign-on cycle is enough.

Use cases

  • Apply organization-wide hardening of powershell on all domain-joined Windows endpoints.
  • Roll out a CIS Benchmark-aligned baseline targeting 'Turn on PowerShell Script Block Logging' via a dedicated GPO.
  • Reduce attack surface for accounts that handle privileged credentials or sensitive data.
  • Standardize the configuration across multiple customer tenants for an MSP-managed fleet.

Security implications

Leaving this policy at default does not directly grant an attacker access, but it widens the blast radius once initial access is obtained – passwords are easier to guess, lockout doesn't fire, audit trails are incomplete, or lateral movement is quieter. Most regulators and cyber-insurance underwriters now expect this control to be in place at least at the recommended level.

How to configure

  1. Open Group Policy Management Console (gpmc.msc) on a domain controller or a workstation with RSAT installed.
  2. Create or edit a GPO linked to the OU containing the target computer configurations. We recommend a dedicated baseline GPO (e.g. SEC – PowerShell) instead of editing Default Domain Policy.
  3. Navigate to Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell.
  4. Open Turn on PowerShell Script Block Logging and set it to Enabled.
  5. Click OK and close the editor.
  6. On the target endpoint, run gpupdate /force (or wait for the next refresh cycle), then verify with rsop.msc or gpresult /h report.html.

Direct registry path: HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging\EnableScriptBlockLogging. You can apply the same change with PowerShell:

New-Item -Path 'HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null
Set-ItemProperty -Path 'HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -Value <value> -Type DWord

Registry mapping

Registry pathHKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
Value nameEnableScriptBlockLogging
Value typeREG_DWORD
Disabled valueNot configured

Frequently asked questions

What does the Turn on PowerShell Script Block Logging Group Policy do?
Logs the full content of all PowerShell script blocks. Generates event 4104. Critical for threat detection.
Where do I find this setting in the GPO editor?
Open <code>gpmc.msc</code>, then navigate to <code>Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell</code> and look for <strong>Turn on PowerShell Script Block Logging</strong>.
What is the Microsoft default value?
<code>Not configured</code> on a fresh Windows install. Domain-joined machines may inherit a different value if a baseline GPO is already in place.
What value do security baselines recommend?
<code>Enabled</code> – aligned with CIS, NIST, and DISA STIG guidance for current Windows versions.
Can I configure this without a GPO?
Yes, by writing to <code>HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging\EnableScriptBlockLogging</code> directly via <code>regedit</code>, PowerShell, or Intune. A GPO is preferred for centrally managed environments because it survives reimaging and is easier to audit.