Export (0) Print
Expand All

Pipeline.Invoke Method ()

Invokes the pipeline synchronously.

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

Dim instance As Pipeline
Dim returnValue As Collection(Of PSObject)

returnValue = instance.Invoke

public Collection<PSObject> Invoke ()
public Collection<PSObject> Invoke ()
public function Invoke () : Collection<PSObject>

Return Value

An array of objects that contain the output of the pipeline. If the pipeline has no output, an empty collection is returned.

Here is an example of calling this method after the pipeline is created.

Pipeline pipeLine = myRunSpace.CreatePipeline("GetProcPSSnapIn01\\get-proc");
Collection<PSObject> results = pipeLine.Invoke();

For an example of applications that use this class, see:

Configuring a Runspace Using RunspaceConfiguration

Configuring a Runspace Using a PowerShell Snap-in

When this method is used to invoke the pipeline, the Windows PowerShell runtime closes the Input pipe.

This method cannot be called when another pipeline is running.

This method cannot be called multiple times on a given pipeline. The state of the pipeline must be NotStarted when Invoke is called. When this method is called, it changes the state of the pipeline to Running. When Invoke is completed, it changes the state of the pipeline to one of following:

  • Completed: The pipeline state is Completed if the pipeline invocation completed successfully.

  • Failed: The pipeline state is Failed if the pipeline invocation failed or one of the commands in the pipeline threw a terminating error.

  • Stopped: The pipeline state is Stopped if the pipeline was stopped by calling Stop or StopAsync.

Applications can get notified about pipeline state changes by registering for the StateChanged event. This event is raised each time the state of the pipeline changes.

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

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Server 2008, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional, Windows Vista, Windows Server 2003 R2, Windows XP, Windows 7, Windows 2008 R2, Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
© 2014 Microsoft