Skip to content

Instantly share code, notes, and snippets.

@jfrantz1-r7
Created August 24, 2018 01:48
Show Gist options
  • Save jfrantz1-r7/bfa2a73dd257409e52786c8f7372efaa to your computer and use it in GitHub Desktop.
Save jfrantz1-r7/bfa2a73dd257409e52786c8f7372efaa to your computer and use it in GitHub Desktop.
function Enable-PSScriptBlockLogging
{
$basePath = “HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging”
if(-not (Test-Path $basePath))
{
$null = New-Item $basePath -Force
}
Set-ItemProperty $basePath -Name EnableScriptBlockLogging -Value “1”
}
function Disable-PSScriptBlockLogging
{
Remove-Item HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging -Force -Recurse
}
function Enable-PSScriptBlockInvocationLogging
{
$basePath = “HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging”
if(-not (Test-Path $basePath))
{
$null = New-Item $basePath -Force
}
Set-ItemProperty $basePath -Name EnableScriptBlockInvocationLogging -Value “1”
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment