Created
November 24, 2023 15:43
-
-
Save gwsales/f7954fd6bc433161418aeee6e54a4484 to your computer and use it in GitHub Desktop.
Enable logging for PowerShell V7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -RunAsAdministrator | |
$Path = "HKLM:\Software\Policies\Microsoft\PowerShellCore" | |
## ScriptBlockLogging | |
if (-not (Test-Path $Path\ScriptBlockLogging)) { | |
$null = New-Item $Path\ScriptBlockLogging -Force | |
} | |
Set-ItemProperty -Path $Path\ScriptBlockLogging -Name EnableScriptBlockLogging -Value "1" -Type Dword | |
## ModuleLogging | |
if (-not (Test-Path $Path\ModuleLogging\ModuleNames)) { | |
$null = New-Item $Path\ModuleLogging\ModuleNames -Force | |
} | |
Set-ItemProperty -Path $Path\ModuleLogging\ModuleNames -Name "*" -Value "*" -Type String | |
Set-ItemProperty -Path $Path\ModuleLogging -Name "EnableModuleLogging" -Value "1" -Type DWord |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment