Chapter 2. Reusable Advanced Functions and Scripts
In the first chapter, we revisited PowerShell and PowerCLI basics. Then, we discussed how we could use the GitHub version to control our work and collaborate with others to work on the same project. We also learned how to use Pester to do unit testing on our work. In this chapter, we are going to cover advanced functions and their implementations in PowerShell. Specifically, we are going to talk about the following topics:
- Specifying function attributes
- Specifying parameter attributes
- Using parameter validation attributes
- Using dynamic parameters
- PowerShell help files
- Creating comment-based help
- Error handling in PowerShell
Before we start discussing advanced functions, let's take a look at normal functions. If you type Get-Help About_Functions
in PowerShell, you can get the details of functions. The description says a function is a list of Windows PowerShell statements that has a name that you can assign. When you run a function...