Skip to content

Commit ea6b169

Browse files
committed
update readme. bump module ver.
1 parent 422dfcf commit ea6b169

File tree

2 files changed

+41
-70
lines changed

2 files changed

+41
-70
lines changed

README.md

Lines changed: 40 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
</div>
1212

13+
`PSParallelPipeline` is a PowerShell module featuring the `Invoke-Parallel` cmdlet, designed to process pipeline input objects in parallel. It mirrors the capabilities of [`ForEach-Object -Parallel`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object) from PowerShell 7.0+, bringing this functionality to Windows PowerShell 5.1, surpassing the constraints of [`Start-ThreadJob`](https://learn.microsoft.com/en-us/powershell/module/threadjob/start-threadjob?view=powershell-7.4).
14+
1315
PSParallelPipeline is a PowerShell Module that includes `Invoke-Parallel`, a cmdlet that allows for parallel processing of input objects, sharing similar capabilities as
1416
[`ForEach-Object -Parallel`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object) introduced in PowerShell v7.0.
1517

16-
This project was inspired by RamblingCookieMonster's [`Invoke-Parallel`](https://github.com/RamblingCookieMonster/Invoke-Parallel) and is developed with Windows PowerShell 5.1 users in mind where the closest there is to parallel pipeline processing is [`Start-ThreadJob`](https://learn.microsoft.com/en-us/powershell/module/threadjob/start-threadjob?view=powershell-7.4).
17-
18-
# What does this Module offer?
18+
# Why Use This Module?
1919

20-
Except for [`-AsJob`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.4#-asjob), this module offers the same capabilities as `ForEach-Object -Parallel` in addition to supporting [Common Parameters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters), a missing feature in the _built-in_ cmdlet.
20+
Except for [`-AsJob`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.4#-asjob), `Invoke-Parallel` delivers the same capabilities as `ForEach-Object -Parallel` and adds support for [Common Parameters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters)—a feature missing from the built-in cmdlet.
2121

22-
## Pipeline streaming capabilities
22+
## Streamlined Pipeline Processing
2323

2424
```powershell
2525
Measure-Command {
@@ -32,109 +32,79 @@ Measure-Command {
3232
# 1.06
3333
```
3434

35-
## Support for [CommonParameters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4)
35+
## Common Parameters Support
3636

37-
Something missing on `ForEach-Object -Parallel` as of `v7.5.0.3`.
37+
Unlike `ForEach-Object -Parallel` (up to v7.5), `Invoke-Parallel` supports [Common Parameters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4), enhancing control and debugging.
3838

3939
```powershell
40-
PS \> 0..5 | ForEach-Object -Parallel { Write-Error $_ } -ErrorAction Stop
41-
# ForEach-Object: The following common parameters are not currently supported in the Parallel parameter set:
42-
# ErrorAction, WarningAction, InformationAction, PipelineVariable
43-
```
44-
45-
A few examples, they should all work properly, please submit an issue if not 😅.
46-
47-
```powershell
48-
PS \> 0..5 | Invoke-Parallel { Write-Error $_ } -ErrorAction Stop
40+
# Stops on first error
41+
0..5 | Invoke-Parallel { Write-Error $_ } -ErrorAction Stop
4942
# Invoke-Parallel: 0
5043
51-
PS \> 0..5 | Invoke-Parallel { Write-Warning $_ } -WarningAction Stop
44+
# Stops on warnings
45+
0..5 | Invoke-Parallel { Write-Warning $_ } -WarningAction Stop
5246
# WARNING: 1
53-
# Invoke-Parallel: The running command stopped because the preference variable "WarningPreference" or common parameter is set to Stop: 1
54-
55-
PS \> 0..5 | Invoke-Parallel { $_ } -PipelineVariable pipe | ForEach-Object { "[$pipe]" }
56-
# [0]
57-
# [1]
58-
# [5]
59-
# [2]
60-
# [3]
61-
# [4]
62-
```
63-
64-
## Improved `-TimeOutSeconds` error message
65-
66-
In `ForEach-Object -Parallel` we get an error message per stopped parallel invocation instead of a single one.
47+
# Invoke-Parallel: The running command stopped because the preference variable "WarningPreference" is set to Stop: 1
6748
68-
```powershell
69-
PS \> 0..10 | ForEach-Object -Parallel { $_; Start-Sleep 5 } -TimeoutSeconds 2
70-
# 0
71-
# 1
72-
# 2
73-
# 3
74-
# 4
75-
# InvalidOperation: The pipeline has been stopped.
76-
# InvalidOperation: The pipeline has been stopped.
77-
# InvalidOperation: The pipeline has been stopped.
78-
# InvalidOperation: The pipeline has been stopped.
79-
# InvalidOperation: The pipeline has been stopped.
49+
# Pipeline variable support
50+
0..5 | Invoke-Parallel { $_ } -PipelineVariable pipe | ForEach-Object { "[$pipe]" }
51+
# [0] [1] [2] [3] [4] [5]
8052
```
8153

82-
With `Invoke-Parallel` you get a single, _friendlier_, error message.
54+
## Cleaner Timeout Handling
8355

8456
```powershell
8557
PS \> 0..10 | Invoke-Parallel { $_; Start-Sleep 5 } -TimeoutSeconds 2
86-
# 0
87-
# 1
88-
# 2
89-
# 3
90-
# 4
58+
# 0 1 2 3 4
9159
# Invoke-Parallel: Timeout has been reached.
9260
```
9361

94-
## [`$using:`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_language_keywords?view=powershell-7.4) Support
62+
## [`$using:`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-7.4#the-using-scope-modifier) Scope Support
9563

96-
Same as `ForEach-Object -Parallel` you can use the `$using:` scope modifier to pass-in variables to the parallel invocations.
64+
Easily pass variables into parallel scopes with the `$using:` modifier, just like `ForEach-Object -Parallel`:
9765

9866
```powershell
9967
$message = 'world!'
10068
'hello ' | Invoke-Parallel { $_ + $using:message }
10169
# hello world!
10270
```
10371

104-
## `-Functions` and `-Variables` Parameters
72+
## `-Variables` and `-Functions` Parameters
10573

106-
Both parameters are a quality of life addition, specially `-Functions`, which adds the locally defined functions to the runspaces [Initial Session State](https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.runspaces.initialsessionstate), a missing feature on `ForEach-Object -Parallel`. This is a much better alternative to passing-in the function definition to the parallel scope.
74+
These parameters enhance usability by simplifying script management:
10775

108-
### [`-Variables` Parameter](./docs/en-US/Invoke-Parallel.md#-variables)
76+
- [`-Variables` Parameter](./docs/en-US/Invoke-Parallel.md#-variables): Pass variables directly to parallel runspaces.
10977

110-
```powershell
111-
'hello ' | Invoke-Parallel { $_ + $msg } -Variables @{ msg = 'world!' }
112-
# hello world!
113-
```
78+
```powershell
79+
'hello ' | Invoke-Parallel { $_ + $msg } -Variables @{ msg = 'world!' }
80+
# hello world!
81+
```
11482
115-
### [`-Functions` Parameter](./docs/en-US/Invoke-Parallel.md#-functions)
83+
- [`-Functions` Parameter](./docs/en-US/Invoke-Parallel.md#-functions): Use local functions in parallel scopes without redefining them.
11684
117-
```powershell
118-
function Get-Message {param($MyParam) $MyParam + 'world!' }
119-
'hello ' | Invoke-Parallel { Get-Message $_ } -Functions Get-Message
120-
# hello world!
121-
```
85+
```powershell
86+
function Get-Message {param($MyParam) $MyParam + 'world!' }
87+
'hello ' | Invoke-Parallel { Get-Message $_ } -Functions Get-Message
88+
# hello world!
89+
```
90+
91+
Both parameters are quality-of-life enhancements, especially `-Functions`, which adds locally defined functions to the runspaces’ [Initial Session State](https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.runspaces.initialsessionstate)—a feature absent in `ForEach-Object -Parallel`. This is a far better option than passing function definitions into the parallel scope.
12292
12393
## Documentation
12494
125-
Check out [__the docs__](./docs/en-US/Invoke-Parallel.md) for information about how to use this Module.
95+
Explore detailed usage in [__the docs__](./docs/en-US/Invoke-Parallel.md).
12696
12797
## Installation
12898
129-
### Gallery
99+
### PowerShell Gallery
130100
131101
The module is available through the [PowerShell Gallery](https://www.powershellgallery.com/packages/PSParallelPipeline):
132102
133103
```powershell
134104
Install-Module PSParallelPipeline -Scope CurrentUser
135105
```
136106

137-
### Source
107+
### From Source
138108

139109
```powershell
140110
git clone 'https://github.com/santisq/PSParallelPipeline.git'
@@ -144,8 +114,9 @@ Set-Location ./PSParallelPipeline
144114

145115
## Requirements
146116

147-
This module has no requirements and is fully compatible with __Windows PowerShell 5.1__ and [__PowerShell Core 7+__](https://github.com/PowerShell/PowerShell).
117+
- Compatible with __Windows PowerShell 5.1__ and __PowerShell Core 7+__
118+
- No external dependencies
148119

149120
## Contributing
150121

151-
Contributions are more than welcome, if you wish to contribute, fork this repository and submit a pull request with the changes.
122+
Contributions are more than welcome! Fork the repo, make your changes, and submit a pull request. Check out the [source](./src/PSParallelPipeline/) for more details.

module/PSParallelPipeline.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RootModule = 'bin/netstandard2.0/PSParallelPipeline.dll'
1212

1313
# Version number of this module.
14-
ModuleVersion = '1.2.2'
14+
ModuleVersion = '1.2.3'
1515

1616
# Supported PSEditions
1717
# CompatiblePSEditions = @()

0 commit comments

Comments
 (0)