Chapter 26. Creating proxy functions

 

A proxy function acts as a wrapper around an existing function, cmdlet, or other command. In its simplest form, a proxy function passes all parameter input through to the wrapped command. Proxy functions are commonly used to add parameters, remove parameters, or otherwise expand or restrict the underlying command, becoming a useful tool for delegated administration. For example, you might provide users with a proxy function that removes a command parameter that you don’t want the user to have access to. When loaded, a proxy function somewhat hides the real, wrapped command. Combined with techniques like constrained remoting endpoints (which we cover in the next chapter), proxy functions can completely hide the wrapped command, becoming the only means by which a user can accomplish a given task.

26.1. What are proxy functions?

A proxy function, which some folks call a wrapper function, is designed to sit on top of an existing command. For example, if you create a proxy function named ConvertTo-HTML, it will hide the real ConvertTo-HTML cmdlet. Whatever parameters you provide as part of the proxy function will become the only ones available to users, enabling you to take away functionality, add functionality, and so forth.

26.2. Creating the proxy function template

26.3. Removing a parameter

26.4. Adding a parameter

26.5. Loading the proxy function

26.6. Lab