Skip to content

Instantly share code, notes, and snippets.

@SeeminglyScience
Created November 22, 2017 22:21
Show Gist options
  • Save SeeminglyScience/3dd4744a2ef046fe9c4d8245f254c577 to your computer and use it in GitHub Desktop.
Save SeeminglyScience/3dd4744a2ef046fe9c4d8245f254c577 to your computer and use it in GitHub Desktop.
Gets the path of active transcripts for the current runspace. Utilizes unsupported code, use at your own risk.
function Get-ActiveTranscriptPath {
[CmdletBinding()]
param()
end {
$flags = [System.Reflection.BindingFlags]'Instance, NonPublic'
$transcriptionData = $Host.Runspace.GetType().
GetProperty('TranscriptionData', $flags).
GetValue($Host.Runspace)
$transcripts = $transcriptionData.GetType().
GetProperty('Transcripts', $flags).
GetValue($transcriptionData)
if (-not $transcripts) {
return
}
foreach ($transcript in $transcripts) {
$transcript.GetType().
GetProperty('Path', $flags).
GetValue($transcript)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment