Summary
We’ve done some interesting stuff in this chapter. We considered some fundamental principles of software engineering, particularly DRY, and saw how we might apply them within PowerShell scripts. We looked in detail at how functions are constructed and how they work. We briefly discussed the difference between basic and advanced functions.
We then discussed the four types of parameters we can use with functions: named, switch, positional, and dynamic parameters. We also learned about the $Args
automatic variable and saw how we can use that to splat parameters into cmdlets in our basic function.
Next, we looked at the many types of attributes we can apply to our parameters to control how the script behaves. We concentrated on the more common attributes but acknowledged the existence of completion attributes and validation attributes.
Finally, we looked at a special type of function – the filter – and saw how we could use it to process pipeline objects...