Closed TsLan closed 3 years ago
There is no need for this option.
There is a much Powershell language solutions, for example
Get-RSJob | Where-Object { $_.HasErrors }
or another filter which you like
take a look to https://www.powershellmagazine.com/2014/10/22/foreach-and-where-magic-methods/
Your code example can be rewitten as
$badjobs, $cleanjobs= (Get-RSJob).Where( { $_.HasErrors }, 'Split' )
#or
$grouping = Get-RSJob | Group-Object HasErrors | Sort-Object Name
$grouping[0].Group, $grouping[1].Group
That's exactly what I was looking to achieve, figured either it was a missed feature, or not needed because of methods I wasn't able to sort out on my own. :)
The samples and examples very much appreciated.
Do you want to request a feature or report a bug? Feature request:
Add switch behavior to get-rsjob (or receive-rsjob) that can filter on 'HasErrors'
What is the current behavior?
It's not currently possible to use get-rsjob, or receive-rsjob to filter out jobs that are either "false" or "true" on "haserrors".
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
I'm leveraging poshrsjob to perform a boottime check against a good number of servers. The scriptblock does an IP test to confirm systems are online before the command to check their boottime is run, however errors can occasionally still occur.
If an error occurs within a given job's scriptblock, a subsequent "get-rsjob | receieve-rsjob" will return any errors encountered at the top of the display. Because these errors are part of the jobs, there should IMHO be a native way within Poshrsjob to filter based on 'haserrors'.
What is the expected behavior?
You've got a wonderful module here, it works extremely well. Just feels like their should be more options for filtering on job errors.
Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts?
not a version issue.
Please provide a code example showing the issue, if applicable: