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:

Step

PowerShell Client

Direction

PowerShell server

1

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 2.2.2.10).

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

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

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

>

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

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

The PowerShell server processes and validates the message.

2

 

<

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

3

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 3.1.5.3.5).

>

 
   

<

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 3.2.5.3.6) 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 3.2.1.2.10), the RunspacePool MUST assign the runspace to the pipeline for execution.

4

 

<

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

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

The PowerShell server starts executing the pipeline.

5

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 3.2.5.3.8), 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 2.2.2.19), ERROR_RECORD (section 2.2.2.20), DEBUG_RECORD (section 2.2.2.22), VERBOSE_RECORD (section 2.2.2.23), WARNING_RECORD (section 2.2.2.24) and PROGRESS_RECORD (section 2.2.2.25) using wxf:ReceiveResponse (section 3.2.5.3.8).

6

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

>

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

7

If the CREATE_PIPELINE message indicated that the pipeline takes input, then the client MUST send an END_OF_PIPELINE_INPUT message (section 2.2.2.18) using wxf:Send message (section 3.1.5.3.5) 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.

8

 

<

Once the pipeline execution is complete:

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

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

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

9

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

   
 
Show:
© 2014 Microsoft