Turn on PowerShell Script Block Logging: registry value EnableScriptBlockLogging and 1 moreUserHKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
- Policy ID
- EnableScriptBlockLogging
- Scope
- Computer Configuration, User Configuration
- Supported on
- At least Microsoft Windows 7 or Windows Server 2008 family
- Source
- Administrative Templates (.admx) for Windows 11 2026 Update (26H2) (version 1.0)
- Category
- Windows Components › Windows PowerShell
Registry
EnableScriptBlockLogging
REG_DWORDUserComputer…\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLoggingHKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging Current key
HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
- Enabled value
- 1
- Disabled value
- 0
Apply with .reg · CMD · PowerShell
UserPer-account setting
.reg
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging] ; Options (use only one) ; Enabled "EnableScriptBlockLogging"=dword:00000001 ; Disabled "EnableScriptBlockLogging"=dword:00000000
CMD
:: Options (use only one) :: Enabled reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 1 /f :: Disabled reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 0 /f
PowerShell
# Common: create the key New-Item -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null # Options (use only one) # Enabled New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 1 -Force | Out-Null # Disabled New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 0 -Force | Out-Null
ComputerMachine-wide setting
.reg
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging] ; Options (use only one) ; Enabled "EnableScriptBlockLogging"=dword:00000001 ; Disabled "EnableScriptBlockLogging"=dword:00000000
CMD
:: Options (use only one) :: Enabled reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 1 /f :: Disabled reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 0 /f
PowerShell
# Common: create the key New-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null # Options (use only one) # Enabled New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 1 -Force | Out-Null # Disabled New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 0 -Force | Out-Null
EnableScriptBlockInvocationLogging
REG_DWORDUserComputer…\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLoggingHKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging Current key
HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
- Checked
- 1
- Unchecked
- 0
- Element
- Log script block invocation start / stop events:
- Value type
- REG_DWORD
Apply with .reg · CMD · PowerShell
UserPer-account setting
.reg
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging] ; Options (use only one) ; Checked "EnableScriptBlockInvocationLogging"=dword:00000001 ; Unchecked "EnableScriptBlockInvocationLogging"=dword:00000000
CMD
:: Options (use only one) :: Checked reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 1 /f :: Unchecked reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 0 /f
PowerShell
# Common: create the key New-Item -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null # Options (use only one) # Checked New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 1 -Force | Out-Null # Unchecked New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 0 -Force | Out-Null
ComputerMachine-wide setting
.reg
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging] ; Options (use only one) ; Checked "EnableScriptBlockInvocationLogging"=dword:00000001 ; Unchecked "EnableScriptBlockInvocationLogging"=dword:00000000
CMD
:: Options (use only one) :: Checked reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 1 /f :: Unchecked reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 0 /f
PowerShell
# Common: create the key New-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null # Options (use only one) # Checked New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 1 -Force | Out-Null # Unchecked New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 0 -Force | Out-Null