Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/powercode/PSParallel
PowerShell module to invoke scriptblocks in parallel runspaces
https://github.com/powercode/PSParallel
Last synced: 5 days ago
JSON representation
PowerShell module to invoke scriptblocks in parallel runspaces
- Host: GitHub
- URL: https://github.com/powercode/PSParallel
- Owner: powercode
- License: mit
- Created: 2015-11-22T09:18:51.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-11-25T01:32:41.000Z (almost 4 years ago)
- Last Synced: 2024-08-02T17:31:24.625Z (3 months ago)
- Language: C#
- Homepage:
- Size: 232 KB
- Stars: 51
- Watchers: 12
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PSParallel
Invoke scriptblocks in parallel runspaces
## Installation
```PowerShell
Install-Module PSParallel
``````PowerShell
# ping all machines in a subnet
(1..255).Foreach{"192.168.0.$_"} | Invoke-Parallel { [PSCustomObject] @{IP=$_;Result=ping.exe -4 -a -w 20 $_}}
```Variables and functions are captured from the parent session.
## Throttling
To control the degree of parallelism, i.e. the number of concurrent runspaces, use the -ThrottleLimit parameter
```PowerShell
# process lots of crash dumps
Get-ChildItem -Recurse *.dmp | Invoke-Parallel -ThrottleLimit 64 -ProgressActivity "Processing dumps" {
[PSCustomObject] @{ Dump=$_; Analysis = cdb.exe -z $_.fullname -c '"!analyze -v;q"'
}
```The overhead of spinning up new PowerShell classes is non-zero. Invoke-Parallel is useful when you have items with high latency or that is long running.
![image](https://github.com/powercode/PSParallel/raw/master/images/Invoke-Parallel.png)
## Contributions
Pull requests and/or suggestions are more than welcome.
### Acknowledgements
The idea and the basis for the implementation comes from [RamblingCookieMonster](https://github.com/RamblingCookieMonster).
Kudos for that implementation also goes to Boe Prox(@proxb) and Sergei Vorobev(@xvorsx).