PoshCode Archive  Artifact [1eddaf656e]

Artifact 1eddaf656eef8e240f97433df3d8a831e39ebbbed4a7e2f9447300bd20471b2f:

  • File Test-Transcribing.ps1 — part of check-in [c666376488] at 2018-06-10 12:57:50 on branch trunk — 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. (user: Oisin Grehan size: 1081)

# encoding: ascii
# api: powershell
# title: Test-Transcribing
# description: 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.
# version: 0.1
# type: function
# author: Oisin Grehan
# license: CC0
# function: Test-Transcribing
# x-poshcode-id: 1500
# x-archived: 2017-05-22T03:21:13
# x-published: 2010-12-01T09:07:00
#
# UPDATE: typo fixed – doh.
# (powershell.exe consolehost only – ISE does not suport transcription)
#
#requires -version 2.0

function Test-Transcribing {
	$externalHost = $host.gettype().getproperty("ExternalHost",
		[reflection.bindingflags]"NonPublic,Instance").getvalue($host, @())

	try {
	    $externalHost.gettype().getproperty("IsTranscribing",
		[reflection.bindingflags]"NonPublic,Instance").getvalue($externalHost, @())
	} catch {
             write-warning "This host does not support transcription."
         }
}