proxb / PoshRSJob

Provides an alternative to PSjobs with greater performance and less overhead to run commands in the background, freeing up the console and allowing throttling on the jobs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Information Stream

sheldonhull opened this issue · comments

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
There does not seem to be a "information" stream for powershell 5.0 write-information functionality. I've tried migrating most of my work away from write-host and ensure write-information is used.

        public System.Management.Automation.PSDataCollection<System.Management.Automation.ErrorRecord> Error;
        public System.Management.Automation.PSDataCollection<System.Management.Automation.VerboseRecord> Verbose;
        public System.Management.Automation.PSDataCollection<System.Management.Automation.DebugRecord> Debug;
        public System.Management.Automation.PSDataCollection<System.Management.Automation.WarningRecord> Warning;
        public System.Management.Automation.PSDataCollection<System.Management.Automation.ProgressRecord> Progress;

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

What is the expected behavior?
Wrap up "information" stream into an output stream for accessing and providing output.

Do you have a tip on where i would add the changes to implement InformationRecord here?
Thinking if this project is still planned on continued support of adding a few custom enhancements and submit them to project to contribute (like estimated time to completion based on custom powershell progress helper class I wrote), and getting information stream back out.

The Innerjob of a RsJob is the underlying powershell object.
From there you can get information stream with: Streams.Information

$job =  $null | Start-RSJob -ScriptBlock {
    Write-Information -MessageData 'x'
}
$job |Wait-RSJob
$job.InnerJob.Streams.Information

I was also wondering about the information stream not being directly available from rsjob. Didn't know it is a Powershell 5.0 feature.

If you want to add it with RsJob you need to change the following file:
PoshRSJob/PoshRSJob/TypeData/PoshRSJob.Types.ps1xml

But i guess that would break backwards compatibility with powershell versions before 5.0

Thanks for this useful update. I started using PSFramework and it solves all my logging woes and is backward compatible, thread safe, and more. If I need to log streams now I just that as it works with various scopes that were a problem in figuring out with nested jobs.