18
Parameters, Validation, and Dynamic Parameters
Parameters are used in PowerShell to accept arguments or user input for a command. Almost all commands accept parameters; there are only a few exceptions in the form of utility functions like those to change drive, such as the function c:
.
PowerShell has an extensive parameter handling and validation system that can be used in scripts and functions. The system allows a developer to make parameters mandatory; to define what, if any, positional binding is allowed; to fill parameters from the pipeline; to describe different parameter sets; and to validate the values passed to a parameter. The wealth of options available makes parameter handling an incredibly involved subject.
This chapter explores ...
Get Mastering PowerShell Scripting - Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.