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.
This sample requires Windows PowerShell 2.0.
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.
This creates a proxy command for a private cmdlet to demonstrate a constrained runspace.
Other ResourcesWriting a Windows PowerShell Host Application