Protokollierung von PowerShell-Skriptblöcken aktivieren: Registrierungswert EnableScriptBlockLogging und 1 weitereComputerHKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging

Richtlinien-ID
EnableScriptBlockLogging
Bereich
Computerkonfiguration, Benutzerkonfiguration
Unterstützt unter
Mindestens Windows 7 oder Windows Server 2008
Quelle
Administrative Templates (.admx) for Windows 11 2026 Update (26H2) (Version 1.0)
Kategorie
Windows-Komponenten › Windows PowerShell

Registrierung

EnableScriptBlockLogging

REG_DWORDComputerBenutzer
Wert bei Aktivierung
1
Wert bei Deaktivierung
0
Mit .reg · CMD · PowerShell anwenden
ComputerComputerweite Einstellung
.reg
Windows Registry Editor Version 5.00

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

; Optionen (nur eine verwenden)
; Aktiviert
"EnableScriptBlockLogging"=dword:00000001
; Deaktiviert
"EnableScriptBlockLogging"=dword:00000000
CMD
:: Optionen (nur eine verwenden)

:: Aktiviert
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 1 /f
:: Deaktiviert
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 0 /f
PowerShell
# Gemeinsam: Schlüssel erstellen
New-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null

# Optionen (nur eine verwenden)
# Aktiviert
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 1 -Force | Out-Null
# Deaktiviert
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 0 -Force | Out-Null
BenutzerEinstellung pro Konto
.reg
Windows Registry Editor Version 5.00

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

; Optionen (nur eine verwenden)
; Aktiviert
"EnableScriptBlockLogging"=dword:00000001
; Deaktiviert
"EnableScriptBlockLogging"=dword:00000000
CMD
:: Optionen (nur eine verwenden)

:: Aktiviert
reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 1 /f
:: Deaktiviert
reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockLogging" /t REG_DWORD /d 0 /f
PowerShell
# Gemeinsam: Schlüssel erstellen
New-Item -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null

# Optionen (nur eine verwenden)
# Aktiviert
New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 1 -Force | Out-Null
# Deaktiviert
New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -PropertyType DWord -Value 0 -Force | Out-Null

EnableScriptBlockInvocationLogging

REG_DWORDComputerBenutzer
Angekreuzt
1
Nicht angekreuzt
0
Element
Start-/Stoppereignisse für den Aufruf von Skriptblöcken protokollieren:
Werttyp
REG_DWORD
Mit .reg · CMD · PowerShell anwenden
ComputerComputerweite Einstellung
.reg
Windows Registry Editor Version 5.00

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

; Optionen (nur eine verwenden)
; Angekreuzt
"EnableScriptBlockInvocationLogging"=dword:00000001
; Nicht angekreuzt
"EnableScriptBlockInvocationLogging"=dword:00000000
CMD
:: Optionen (nur eine verwenden)

:: Angekreuzt
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 1 /f
:: Nicht angekreuzt
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 0 /f
PowerShell
# Gemeinsam: Schlüssel erstellen
New-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null

# Optionen (nur eine verwenden)
# Angekreuzt
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 1 -Force | Out-Null
# Nicht angekreuzt
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 0 -Force | Out-Null
BenutzerEinstellung pro Konto
.reg
Windows Registry Editor Version 5.00

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

; Optionen (nur eine verwenden)
; Angekreuzt
"EnableScriptBlockInvocationLogging"=dword:00000001
; Nicht angekreuzt
"EnableScriptBlockInvocationLogging"=dword:00000000
CMD
:: Optionen (nur eine verwenden)

:: Angekreuzt
reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 1 /f
:: Nicht angekreuzt
reg add "HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v "EnableScriptBlockInvocationLogging" /t REG_DWORD /d 0 /f
PowerShell
# Gemeinsam: Schlüssel erstellen
New-Item -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Force | Out-Null

# Optionen (nur eine verwenden)
# Angekreuzt
New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 1 -Force | Out-Null
# Nicht angekreuzt
New-ItemProperty -Path 'HKCU:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockInvocationLogging' -PropertyType DWord -Value 0 -Force | Out-Null