Getting started with Parameter Classes
Parameter Classes enable developers to be more permissive in what input they accept and does all the input interpretation for the developer.
Implementing Parameter Classes
Parameter classes define new types as input types. In many instances, implementing them is as simple replacing the expected type on the parameter definition:
[CmdletBinding()] param ( [string] $ComputerName )
[CmdletBinding()] param ( [PSFComputer] $ComputerName )
With this your command will correctly understand dns resolution objects, the output of Get-ADComputer, connection strings or any of a dozen other legal input types.
- It is possible to extend the list of legal input types.
- It is possible to teach it to understand PSCustomObjects, no need to code in C#.