Created
August 24, 2018 01:44
-
-
Save jfrantz1-r7/fa77396c2d523c72ac224a0b03c4ed62 to your computer and use it in GitHub Desktop.
This file contains 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
function Enable-PSTranscription | |
{ | |
[CmdletBinding()] | |
param( | |
$OutputDirectory, | |
[Switch] $IncludeInvocationHeader | |
) | |
## Ensure the base path exists | |
$basePath = “HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription” | |
if(-not (Test-Path $basePath)) | |
{ | |
$null = New-Item $basePath -Force | |
} | |
## Enable transcription | |
Set-ItemProperty $basePath -Name EnableTranscripting -Value 1 | |
## Set the output directory | |
if($PSCmdlet.MyInvocation.BoundParameters.ContainsKey(“OutputDirectory”)) | |
{ | |
Set-ItemProperty $basePath -Name OutputDirectory -Value $OutputDirectory | |
} | |
## Set the invocation header | |
if($IncludeInvocationHeader) | |
{ | |
Set-ItemProperty $basePath -Name IncludeInvocationHeader -Value 1 | |
} | |
} | |
function Disable-PSTranscription | |
{ | |
Remove-Item HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription -Force -Recurse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment