November 2018
Intermediate to advanced
566 pages
17h 15m
English
PowerShell provides a range of options for parameter validation. These are simply pre-recorded functions that reduce the amount of time you spend validating the input, and at the same time give errors that are readable. PowerShell also allows us to create our own parameter validation logic. However, that is out of the scope of this book.
In our recipe, we use the ValidateSet attribute, which accepts a series of inputs as a set and ensures that the input sent to TotalTime is one of 5, 10, 15, or 20 seconds. There are more validation options available, such as ValidateNotNullOrEmpty, ValidateRange, ValidateCount, ValidatePattern, or even—when you have your own script block —ValidateScript.
Read now
Unlock full access