src/Private/Write-PleaseWorkTaskExecutorStream.ps1
|
using namespace System.Management.Automation <# .SYNOPSIS Replays buffered executor streams through the calling cmdlet. .DESCRIPTION Replays buffered executor streams through the calling cmdlet. This is useful when the executor is running in a different runspace than the calling cmdlet, and the executor's streams are not automatically replayed in the calling runspace. .EXAMPLE Basic usage: Write-PleaseWorkTaskExecutorStream -Executor $Executor -Caller $PSCmdlet #> function Write-PleaseWorkTaskExecutorStream { [CmdletBinding()] [OutputType([void])] param ( [Parameter(Mandatory)] [powershell] $Executor, [Parameter(Mandatory)] [PSCmdlet] $Caller ) foreach ($InformationRecord in $Executor.Streams.Information) { $Caller.WriteInformation($InformationRecord) } foreach ($ErrorRecord in $Executor.Streams.Error) { $Caller.WriteError($ErrorRecord) } foreach ($WarningRecord in $Executor.Streams.Warning) { $Caller.WriteWarning($WarningRecord.Message) } foreach ($VerboseRecord in $Executor.Streams.Verbose) { $Caller.WriteVerbose($VerboseRecord.Message) } foreach ($DebugRecord in $Executor.Streams.Debug) { $Caller.WriteDebug($DebugRecord.Message) } foreach ($ProgressRecord in $Executor.Streams.Progress) { $Caller.WriteProgress($ProgressRecord) } } |