Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Runspace11 Sample

This sample shows how to use the ProxyCommand class to create a proxy command that calls an existing cmdlet, but restricts the set of available parameters. The proxy command is then added to an initial session state that is used to create a constrained runspace. This means that the user can access the functionality of the cmdlet only through the proxy command.

Requirements

This sample requires Windows PowerShell 2.0.

Demonstrates

This sample demonstrates the following.

  • Creating a CommandMetadata object that describes the metadata of an existing cmdlet.

  • Creating an InitialSessionState object.

  • Modifying the cmdlet metadata to remove a parameter of the cmdlet.

  • Adding the cmdlet to the InitialSessionState object and making the cmdlet private.

  • Creating a proxy function that calls the existing cmdlet, but exposes only a restricted set of parameters.

  • Adding the proxy function to the initial session state.

  • Creating a PowerShell object that uses the Runspace object.

  • Calling the private cmdlet and the proxy function using a PowerShell object to demonstrate the constrained runspace.

Example

This creates a proxy command for a private cmdlet to demonstrate a constrained runspace.

See Also

Community Additions

Show:
© 2015 Microsoft