Activer la journalisation de blocs de scripts PowerShell : valeur de Registre EnableScriptBlockLogging et 1 autresOrdinateurHKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging

ID de stratégie
EnableScriptBlockLogging
Étendue
Configuration ordinateur, configuration utilisateur
Pris en charge sur
Au moins Microsoft Windows 7 ou famille Windows Server 2008
Source
Administrative Templates (.admx) for Windows 11 2026 Update (26H2) (version 1.0)
Catégorie
Composants Windows › Windows PowerShell

Registre

EnableScriptBlockLogging

REG_DWORDOrdinateurUtilisateur
Valeur si activée
1
Valeur si désactivée
0
Appliquer avec .reg · CMD · PowerShell
OrdinateurParamètre valable pour tout l’ordinateur
.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging]

; Options (en utiliser une seule)
; Activé
"EnableScriptBlockLogging"=dword:00000001
; Désactivé
"EnableScriptBlockLogging"=dword:00000000
CMD
:: Options (en utiliser une seule)

:: Activé
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 1 /f
:: Désactivé
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 0 /f
PowerShell
# Commun : créer la clé
New-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null

# Options (en utiliser une seule)
# Activé
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 1 -Force | Out-Null
# Désactivé
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 0 -Force | Out-Null
UtilisateurParamètre par compte
.reg
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging]

; Options (en utiliser une seule)
; Activé
"EnableScriptBlockLogging"=dword:00000001
; Désactivé
"EnableScriptBlockLogging"=dword:00000000
CMD
:: Options (en utiliser une seule)

:: Activé
reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 1 /f
:: Désactivé
reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 0 /f
PowerShell
# Commun : créer la clé
New-Item -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null

# Options (en utiliser une seule)
# Activé
New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 1 -Force | Out-Null
# Désactivé
New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 0 -Force | Out-Null

EnableScriptBlockInvocationLogging

REG_DWORDOrdinateurUtilisateur
Cochée
1
Décochée
0
Élément
Consigner les événements de début/de fin des appels de blocs de scripts :
Type de valeur
REG_DWORD
Appliquer avec .reg · CMD · PowerShell
OrdinateurParamètre valable pour tout l’ordinateur
.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging]

; Options (en utiliser une seule)
; Cochée
"EnableScriptBlockInvocationLogging"=dword:00000001
; Décochée
"EnableScriptBlockInvocationLogging"=dword:00000000
CMD
:: Options (en utiliser une seule)

:: Cochée
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 1 /f
:: Décochée
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 0 /f
PowerShell
# Commun : créer la clé
New-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null

# Options (en utiliser une seule)
# Cochée
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 1 -Force | Out-Null
# Décochée
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 0 -Force | Out-Null
UtilisateurParamètre par compte
.reg
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging]

; Options (en utiliser une seule)
; Cochée
"EnableScriptBlockInvocationLogging"=dword:00000001
; Décochée
"EnableScriptBlockInvocationLogging"=dword:00000000
CMD
:: Options (en utiliser une seule)

:: Cochée
reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 1 /f
:: Décochée
reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 0 /f
PowerShell
# Commun : créer la clé
New-Item -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null

# Options (en utiliser une seule)
# Cochée
New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 1 -Force | Out-Null
# Décochée
New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 0 -Force | Out-Null