Created
November 22, 2017 22:21
-
-
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.
This file contains hidden or 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 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