{"id":23379005,"url":"https://github.com/santisq/psparallelpipeline","last_synced_at":"2025-08-26T14:04:25.699Z","repository":{"id":142176800,"uuid":"559658523","full_name":"santisq/PSParallelPipeline","owner":"santisq","description":"Parallel processing of pipeline input objects!","archived":false,"fork":false,"pushed_at":"2025-03-19T19:39:12.000Z","size":203,"stargazers_count":29,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T01:41:07.678Z","etag":null,"topics":["concurrency","csharp","foreach","multithreading","parallel","parallel-processing","powershell","runspace"],"latest_commit_sha":null,"homepage":"https://www.powershellgallery.com/packages/PSParallelPipeline","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/santisq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-30T19:35:31.000Z","updated_at":"2025-03-29T01:03:01.000Z","dependencies_parsed_at":"2024-01-14T04:43:19.257Z","dependency_job_id":"8fc7b836-3207-4e35-93bf-592171545336","html_url":"https://github.com/santisq/PSParallelPipeline","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santisq%2FPSParallelPipeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santisq%2FPSParallelPipeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santisq%2FPSParallelPipeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santisq%2FPSParallelPipeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/santisq","download_url":"https://codeload.github.com/santisq/PSParallelPipeline/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248294800,"owners_count":21079976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","csharp","foreach","multithreading","parallel","parallel-processing","powershell","runspace"],"created_at":"2024-12-21T19:16:09.640Z","updated_at":"2025-08-26T14:04:25.693Z","avatar_url":"https://github.com/santisq.png","language":"C#","readme":"\u003ch1 align=\"center\"\u003ePSParallelPipeline\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n\u003csub\u003eParallel processing of pipeline input objects!\u003c/sub\u003e\n\u003cbr /\u003e\u003cbr /\u003e\n\n[![build](https://github.com/santisq/PSParallelPipeline/actions/workflows/ci.yml/badge.svg)](https://github.com/santisq/PSParallelPipeline/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/santisq/PSParallelPipeline/branch/main/graph/badge.svg?token=b51IOhpLfQ)](https://codecov.io/gh/santisq/PSParallelPipeline)\n[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/PSParallelPipeline?label=gallery)](https://www.powershellgallery.com/packages/PSParallelPipeline)\n[![LICENSE](https://img.shields.io/github/license/santisq/PSParallelPipeline)](https://github.com/santisq/PSParallelPipeline/blob/main/LICENSE)\n\n\u003c/div\u003e\n\n`PSParallelPipeline` is a PowerShell module featuring the `Invoke-Parallel` cmdlet, designed to process pipeline input objects in parallel using multithreading. 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).\n\n# Why Use This Module?\n\nExcept 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. For larger datasets or time-intensive tasks, `Invoke-Parallel` can significantly reduce execution time compared to sequential processing.\n\n## Streamlined Pipeline Processing\n\n`Invoke-Parallel` can stream objects as they complete, a capability shared with `ForEach-Object -Parallel`. Each iteration sleeps for 1 second, but `Select-Object -First 1` stops the pipeline after the first object is available, resulting in a total time of ~1 second instead of 11 seconds if all `0..10` were processed sequentially.\n\n```powershell\nMeasure-Command {\n    $null | Invoke-Parallel { 0..10 | ForEach-Object { Start-Sleep 1; $_ } } |\n        Select-Object -First 1\n} | Select-Object TotalSeconds\n\n# TotalSeconds\n# ------------\n#        1.06\n```\n\n## Common Parameters Support\n\nUnlike `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), enhancing control and debugging.\n\n```powershell\n# Stops on first error\n0..5 | Invoke-Parallel { Write-Error $_ } -ErrorAction Stop\n# Invoke-Parallel: 0\n\n# Stops on warnings\n0..5 | Invoke-Parallel { Write-Warning $_ } -WarningAction Stop\n# WARNING: 1\n# Invoke-Parallel: The running command stopped because the preference variable \"WarningPreference\" is set to Stop: 1\n\n# Pipeline variable support\n0..5 | Invoke-Parallel { $_ * 2 } -PipelineVariable pipe | ForEach-Object { \"[$pipe]\" }\n# [6] [0] [8] [2] [4] [10]\n```\n\n## Cleaner Timeout Handling\n\nGet a single, friendly timeout message instead of multiple errors:\n\n```powershell\n0..10 | Invoke-Parallel { $_; Start-Sleep 5 } -TimeoutSeconds 2\n# 0 1 2 3 4\n# Invoke-Parallel: Timeout has been reached.\n```\n\n## [`$using:`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes#the-using-scope-modifier) Scope Support\n\nEasily pass variables into parallel scopes with the `$using:` modifier, just like `ForEach-Object -Parallel`:\n\n```powershell\n$message = 'world!'\n'hello ' | Invoke-Parallel { $_ + $using:message }\n# hello world!\n```\n\n## `-Variables`, `-Functions`, `-ModuleNames`, and `-ModulePaths` Parameters\n\n- [`-Variables` Parameter](./docs/en-US/Invoke-Parallel.md#-variables): Pass variables directly to parallel runspaces.\n\n    ```powershell\n    'hello ' | Invoke-Parallel { $_ + $msg } -Variables @{ msg = 'world!' }\n    # hello world!\n    ```\n\n- [`-Functions` Parameter](./docs/en-US/Invoke-Parallel.md#-functions): Use local functions in parallel scopes without redefining them.\n\n    ```powershell\n    function Get-Message {param($MyParam) $MyParam + 'world!' }\n    'hello ' | Invoke-Parallel { Get-Message $_ } -Functions Get-Message\n    # hello world!\n    ```\n\n- [`-ModuleNames` Parameter](./docs/en-US/Invoke-Parallel.md#-modulenames): Import system-installed modules into parallel runspaces by name, using modules discoverable via `$env:PSModulePath`.\n\n    ```powershell\n    Import-Csv users.csv | Invoke-Parallel { Get-ADUser $_.UserPrincipalName } -ModuleNames ActiveDirectory\n    # Imports ActiveDirectory module for Get-ADUser\n    ```\n\n- [`-ModulePaths` Parameter](./docs/en-US/Invoke-Parallel.md#-modulepaths): Import custom modules from specified directory paths into parallel runspaces.\n\n    ```powershell\n    $moduleDir = Join-Path $PSScriptRoot \"CustomModule\"\n    0..10 | Invoke-Parallel { Get-CustomCmdlet } -ModulePaths $moduleDir\n    # Imports custom module for Get-CustomCmdlet\n    ```\n\nThese parameters are a quality-of-life enhancement, especially `-Functions`, which incorporates 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` and a far better option than passing function definitions into the parallel scope. The new `-ModuleNames` and `-ModulePaths` parameters simplify module integration by automatically loading system-installed and custom modules, respectively, eliminating the need for manual `Import-Module` calls within the script block.\n\n# Documentation\n\nExplore detailed usage in [__the docs__](./docs/en-US/Invoke-Parallel.md).\n\n# Installation\n\n## PowerShell Gallery\n\nThe module is available through the [PowerShell Gallery](https://www.powershellgallery.com/packages/PSParallelPipeline):\n\n```powershell\nInstall-Module PSParallelPipeline -Scope CurrentUser\n```\n\n## From Source\n\n```powershell\ngit clone 'https://github.com/santisq/PSParallelPipeline.git'\nSet-Location ./PSParallelPipeline\n./build.ps1\n```\n\n# Requirements\n\n- Compatible with _Windows PowerShell 5.1_ and _PowerShell 7+_\n- No external dependencies\n\n# Contributing\n\nContributions are more than welcome! Fork the repo, make your changes, and submit a pull request. Check out the [source](./src/PSParallelPipeline/) for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantisq%2Fpsparallelpipeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsantisq%2Fpsparallelpipeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantisq%2Fpsparallelpipeline/lists"}