PowerShell.BeginInvoke Method (PSDataCollection, PSDataCollection, PSInvocationSettings, AsyncCallback, Object)

Asynchronously runs the commands of the PowerShell object pipeline by using a specified input buffer, invocation settings, callback method, and output buffer. This method is introduced in Windows PowerShell 2.0.

Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)

Dim instance As PowerShell
Dim input As PSDataCollection(Of TInput)
Dim output As PSDataCollection(Of TOutput)
Dim settings As PSInvocationSettings
Dim callback As AsyncCallback
Dim state As Object
Dim returnValue As IAsyncResult

returnValue = instance.BeginInvoke(input, output, settings, callback, state)

public IAsyncResult BeginInvoke<TInput,TOutput> (
	PSDataCollection<TInput> input,
	PSDataCollection<TOutput> output,
	PSInvocationSettings settings,
	AsyncCallback callback,
	Object state



The type of the objects used as input to the first command of the pipeline.


The type of the output objects expected from invoking the commands of the pipeline.



A PSDataCollection of type parameter TInput that contains input data for the first command of the pipeline.


A PSDataCollection of type parameter TOutput that contains the output of the pipeline.


A PSInvocationSettings object that specifies Windows PowerShell defined options used when invoking the commands, such as which host should be used when the commands are invoked.


An AsyncCallback delegate that references a call to make when the BeginInvoke(Generic PSDataCollection,Generic PSDataCollection,PSInvocationSettings,AsyncCallback,Object) call is complete.


A user-supplied state to use when the callback method is called.

Return Value

An IAsyncResult interface that represents the status of the asynchronous operation. The EndInvoke method uses this interface to determine when to return the results of the operation to the supplied output buffer.

When this method is used, calls to the EndInvoke method return a null buffer.

Exception typeCondition

Cannot perform the operation because the operation is already started, or there are no commands in the pipeline.


The PowerShell object is disposed.

When this method is called, invocation does not begin until the application completes adding data to the buffer. The caller of the BeginInvoke(Generic PSDataCollection,Generic PSDataCollection,PSInvocationSettings,AsyncCallback,Object) must call Complete after all input is written to the input buffer. If you do not call the Complete method, Windows PowerShell will continue to wait for input data and not invoke the pipeline. If you observe that the invocation is not doing anything, this might be the reason.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


Target Platforms

© 2015 Microsoft