Chapter 7 quick reference

To

Do this

Display help for a command that is missing a parameter

Use the HelpMessage parameter property.

Make a parameter mandatory

Use the Mandatory parameter property in the param section of the function.

Implement -verbose in a function

Use the [cmdletbinding] attribute and write the messages via the Write-Verbose cmdlet.

Implement the -whatif switched parameter in a function

Use the [cmdletbinding()] attribute with the SupportsShouldProcess property.

Ensure that only defined parameters pass values to the function

Use the [cmdletbinding()] attribute.

Group sets of parameters for ease of use and checking

Create a parameter set via the ParameterSetName parameter property.

Assign a specific position to a parameter ...

Get Windows PowerShell™ 3.0 Step by Step now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.