< Back

Invoke-ParallelProcessing

Sat Jan 18, 2020 6:25 pm

NAME Invoke-ParallelProcessing



SYNOPSIS





SYNTAX

Invoke-ParallelProcessing [-ScriptBlock] <ScriptBlock[]> [-ArgumentList] <Object[]> [-MaxThreads <Int32>]

[-UseLocalScope] [-InvocationMode <ParallelExecutionHelper.InvocationMode>] [-MaxExecutionTime <TimeSpan>]

[<CommonParameters>]





DESCRIPTION

Invokes one or more scriptblocks in parallel. A list of arguments can be provided to the scriptblocks in one of

three modes. See 'Parameters' for details.





PARAMETERS

-ScriptBlock <ScriptBlock[]>

Specifies the list of scripts that should be executed in parallel.



Required? true

Position? 0

Default value (none)

Accept pipeline input? false

Accept wildcard characters? false



-ArgumentList <Object[]>

Specifies the list of arguments that will be available to the scripts.



Note: Different arguments will be available to each script depending on the InvocationMode parameter.



Required? true

Position? 1

Default value (none)

Accept pipeline input? false

Accept wildcard characters? false



-MaxThreads <Int32>

The maximum number of parallel threads that will be active at any given time.



The number of threads must be between 1 and 64.



When configuring this setting make sure to account for the relative performance impact of each script and the

machine hardware specifications.



Required? false

Position? named

Default value 4

Accept pipeline input? false

Accept wildcard characters? false



-UseLocalScope

Specifies whether the child runspaces will be executed in the parent's local scope.



Required? false

Position? named

Default value false

Accept pipeline input? false

Accept wildcard characters? false



-InvocationMode <ParallelExecutionHelper.InvocationMode>

Specifies how to pass the arguments from the ArgumentList parameter to the scripts from the ScriptBlock

parameter.



OneArgumentToEachScriptBlock

Each script will receive exactly one element from the ArgumentList array. Common usage: Execute a script

against several computers - the ArgumentList will contain the list of computer names.



AllArgumentsToEachScriptBlock

Each script will receive all elements from the ArgumentList array. Common usage: Execute several different

scripts against a single computer - the ArgumentList can contain various configuration data.



MatchScriptToArgumentByIndex

Script ScriptBlock[0] will receive argument ArgumentList[0], Script ScriptBlock[1] will receive argument

ArgumentList[1], etc. Common usage: Execute several unrelated tasks in parallel.



Required? false

Position? named

Default value OneArgumentToEachScriptBlock

Accept pipeline input? false

Accept wildcard characters? false



-MaxExecutionTime [<Nullable<TimeSpan>>]

The maximum time that the parent process will wait for the child processes to complete.



If a thread has not completed by the time the MaxExecutionTime has passed the job will be stopped and a

timeout message will be logged in the Error property of the returned object.



Required? false

Position? named

Default value Null (infinite)

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS





RELATED LINKS