PoshCode Logo PowerShell Code Repository

Test-Transcribing by Oisin Grehan 4 years ago (modification of post by Oisin Grehan view diff)
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1500"></script>download | new post

Start-Transcript and Stop-Transcript will start and stop a file-based transcription log. However, there is no way to tell (afaik) if the current host is actually transcribing. Test-Transcribing will return $true if we are transcribing, $false if not.

UPDATE: typo fixed – doh.

(powershell.exe consolehost only – ISE does not suport transcription)

  1. #requires -version 2.0
  2.  
  3. function Test-Transcribing {
  4.         $externalHost = $host.gettype().getproperty("ExternalHost",
  5.                 [reflection.bindingflags]"NonPublic,Instance").getvalue($host, @())
  6.  
  7.         try {
  8.             $externalHost.gettype().getproperty("IsTranscribing",
  9.                 [reflection.bindingflags]"NonPublic,Instance").getvalue($externalHost, @())
  10.         } catch {
  11.              write-warning "This host does not support transcription."
  12.          }
  13. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me