Reputation: 12743
I have some Powershell objects (created with [PowerShell]::Create()
) acting as threads in my powershell application.
How can I show the streams data (Verbose and Error streams) on the invoker's console, during the run itself, and not only after the thread terminates?
Upvotes: 2
Views: 636
Reputation: 12743
$VerbosePreference
needs to be set to "continue" on the thread environment. It can be also applied to the pipeline before the real execution script:
$pipeline = [PowerShell]::Create()
$pipeline.RunspacePool = $pool
if ($PSBoundParameters['Verbose'].IsPresent) {
$pipeline.AddScript({ $VerbosePreference = "Continue" }, $false).Invoke()
$pipeline.Commands.Clear()
}
... $pipeline execution code ...
Upvotes: 2