Skip to content

Instantly share code, notes, and snippets.

@jfrantz1-r7
Created August 24, 2018 01:44
Show Gist options
  • Save jfrantz1-r7/fa77396c2d523c72ac224a0b03c4ed62 to your computer and use it in GitHub Desktop.
Save jfrantz1-r7/fa77396c2d523c72ac224a0b03c4ed62 to your computer and use it in GitHub Desktop.
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