3.2.5.4.14 GET_COMMAND_METADATA Message

The syntax of this message is specified in section 2.2.2.14.

While sending responses to the client, the server MUST use the same PSRP messages that are used for the pipeline: PIPELINE_OUTPUT (section 3.2.5.4.19), ERROR_RECORD (section 3.2.5.4.20), DEBUG_RECORD (section 3.2.5.4.22), VERBOSE_RECORD (section 3.2.5.4.23), WARNING_RECORD (section 3.2.5.4.24), PROGRESS_RECORD (section 3.2.5.4.25), and INFORMATION_RECORD (section 3.2.5.4.26).

The server SHOULD perform the following steps upon receiving this message:

  1. Extract the PID from the message (section 2.2.1) and use the same PID while sending responses back to the client.

  2. The server MUST create a collection of command metadata which SHOULD be populated by collecting the available commands metadata in the RunspacePool from the higher layer by extracting the extended properties Name, CommandType, Namespace, and ArgumentList from the GET_COMMAND_METADATA message (section 2.2.2.14) and passing them to the higher layer.

  3. After all the commands metadata is collected, the server MUST first construct a CommandMetadataCount (section 2.2.3.21) object using the collected number of commands metadata and send it to the client using the PIPELINE_OUTPUT message (section 3.2.5.4.19). For each and every command metadata in the collection, the server MUST construct a CommandMetadata object (section 2.2.3.22) and send it to the client using the PIPELINE_OUTPUT message (section 3.2.5.4.19).

  4. After all the CommandMetadata objects (section 2.2.3.22) are sent, the server MUST send a PIPELINE_STATE message (section 3.2.5.4.21) with Completed state to the client.

If, for any reason, the server has to close a RunspacePool in the middle of performing these steps, the server SHOULD send a PIPELINE_STATE message (section 3.2.5.4.21) with Stopped state to the client and stop performing the next steps.