Skip to content

Instantly share code, notes, and snippets.

@gwsales
Created November 24, 2023 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwsales/f7954fd6bc433161418aeee6e54a4484 to your computer and use it in GitHub Desktop.
Save gwsales/f7954fd6bc433161418aeee6e54a4484 to your computer and use it in GitHub Desktop.
Enable logging for PowerShell V7
#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