Export (0) Print
Expand All

4.1.3 Creating and Invoking a Pipeline

The typical sequence, with respect to the PowerShell remoting protocol, for creating and invoking a successful pipeline on the PowerShell server is shown in the following table:


PowerShell Client


PowerShell server


The RunspacePool MUST be in the Opened state on the PowerShell client (section 4.2.1).

The PowerShell client constructs a CREATE_PIPELINE message (section

The PowerShell client Fragments the message into multiple fragments as needed (section 2.2.4).

The PowerShell client initializes the pipeline state (section to Running.

The PowerShell client sends the first fragment to the PowerShell server using wxf:Command message (section


The PowerShell server extracts the PID from the message (section 2.2.1) and stores this value as pipeline's GUID (section

The PowerShell server initializes the pipeline state (section to NotStarted.

The PowerShell server processes and validates the message.




The PowerShell server sends a success message (section if validation is successful.


If the pipeline message is fragmented into multiple fragments, then rest of the fragments (starting from second fragment) are sent individually using wxf:Send message (section




The PowerShell server collects all the fragments until the end fragment (section 2.2.4) is received.

The each wxf:Send message received from the client, the PowerShell server sends a wxf:SendResponse message (see section to the client.

The PowerShell server processes all the fragments and understands the pipeline to execute.

If a runspace in the RunspacePool is available (section, the RunspacePool MUST assign the runspace to the pipeline for execution.




The PowerShell server changes the pipeline state (section to Running.

Note this state change information is not sent to the PowerShell client.

The PowerShell server starts executing the pipeline.


The PowerShell client sends a wxf:Receive message to start receiving data from the pipeline on the PowerShell server. After each received wxf:ReceiveResponse message (see section, the PowerShell client sends another wxf:Receive message until the server indicates that the pipeline is completed (step 8). Sending of input (steps 6 and 7) can happen in parallel.




The PowerShell server sends the pipeline result messages (if any): PIPELINE_OUTPUT (section, ERROR_RECORD (section, DEBUG_RECORD (section, VERBOSE_RECORD (section, WARNING_RECORD (section and PROGRESS_RECORD (section using wxf:ReceiveResponse (section


The PowerShell client MAY send any PIPELINE_INPUT messages (section to the pipeline using wxf:Send message (section if the CREATE_PIPELINE message indicated that the pipeline takes input.


The PowerShell server processes the message and dispatches the input to pipeline execution.


If the CREATE_PIPELINE message indicated that the pipeline takes input, then the client MUST send an END_OF_PIPELINE_INPUT message (section using wxf:Send message (section after sending all (possibly zero) the PIPELINE_INPUT messages to the server.


The PowerShell server processes the END_OF_PIPELINE_INPUT message and notifies the pipeline execution that no more Input is expected.




Once the pipeline execution is complete:

  • The PowerShell server removes the entry for this pipeline in the RunspacePool's pending pipelines queue (section

  • The PowerShell server changes the pipeline state (section to Completed.

  • The PowerShell server constructs the Completed PIPELINE_STATE message (section and sends it to the PowerShell client using wxf:ReceiveResponse (section


The PowerShell client changes the pipeline state (section to Completed.

© 2014 Microsoft