en-US windows computer user

Turn on PowerShell Script Block Logging

Verified with Windows 11 25H2 — updated on July 30, 2026

Windows 11 25H2

Supported on: At least Microsoft Windows 7 or Windows Server 2008 family

Path in the GPO console

Computer Configuration\Administrative Templates\Windows Components\Windows PowerShell

Description

This policy setting enables logging of all PowerShell script input to the Microsoft-Windows-PowerShell/Operational event log. If you enable this policy setting, Windows PowerShell will log the processing of commands, script blocks, functions, and scripts - whether invoked interactively, or through automation. If you disable this policy setting, logging of PowerShell script input is disabled. If you enable the Script Block Invocation Logging, PowerShell additionally logs events when invocation of a command, script block, function, or script starts or stops. Enabling Invocation Logging generates a high volume of event logs. Note: This policy setting exists under both Computer Configuration and User Configuration in the Group Policy Editor. The Computer Configuration policy setting takes precedence over the User Configuration policy setting.

Registry

HKLM Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
HKCU Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging

Value name: EnableScriptBlockLogging

Enabled: EnableScriptBlockLogging = 1

Disabled: EnableScriptBlockLogging = 0

More options available

Options

Log script block invocation start / stop events:
EnableScriptBlockInvocationLogging boolean

MDM / Intune (CSP)

Device ./Device/Vendor/MSFT/Policy/Config/WindowsPowerShell/TurnOnPowerShellScriptBlockLogging
User ./User/Vendor/MSFT/Policy/Config/WindowsPowerShell/TurnOnPowerShellScriptBlockLogging
DeviceUser Since Windows 10, version 1803 [10.0.17134] and later Official mapping (Microsoft Learn)

Microsoft Learn documentation Mapping data: Microsoft Learn (CC BY 4.0)

Export Builder

BETA

Configure the state, scope and options, then generate .reg, PowerShell, Intune and SCCM outputs — or add the setting to a multi-setting collection.

These exports write the registry — this is not a managed GPO.

Scope

.reg file

Windows Registry Editor Version 5.00

; Exported from gporais.com
; Policy: Turn on PowerShell Script Block Logging
; State: Enabled
; Scope: Computer (HKLM)
; Supported on: At least Microsoft Windows 7 or Windows Server 2008 family

[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging]
"EnableScriptBlockLogging"=dword:00000001
"EnableScriptBlockInvocationLogging"=dword:00000000
More formats (PowerShell, Intune, SCCM)

PowerShell

# Exported from gporais.com
# Policy: Turn on PowerShell Script Block Logging
# State: Enabled
# Scope: Computer (HKLM)
# Supported on: At least Microsoft Windows 7 or Windows Server 2008 family

$path = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging'
New-Item -Path $path -Force | Out-Null
Set-ItemProperty -Path $path -Name 'EnableScriptBlockLogging' -Value 1 -Type DWord
Set-ItemProperty -Path $path -Name 'EnableScriptBlockInvocationLogging' -Value 0 -Type DWord

Building a multi-setting collection? Add this setting and generate combined .reg / PowerShell / GPO scripts.

Open the Builder

Embed this policy on your site

What to embed
Theme

Adds one script line: the theme follows your site’s appearance and the height fits the content. If your site blocks scripts, the embed follows the visitor’s system theme.

Preview