July 2018
Beginner
552 pages
13h 18m
English
With a function keyword, the name, and a script block, you are well on your way to creating great reusable code. The next step to improve code quality is to introduce proper parameters.
The parameter attribute decorates each one of your parameters, and allows you to set several options. The most common one is the declaration of a mandatory parameter, as seen in the next code sample:
# The basic parameter attributeparam( [Parameter()] $YourParameter)# A mandatory parameterparam( [Parameter(Mandatory)] $YourParameter)# A help message for mandatory parametersparam( [Parameter( Mandatory, HelpMessage = 'This is visible when needed' )] $YourParameter)# Hidden Parametersfunction fun{ param ( [Parameter(DontShow)] $CatchMeIfYouCan ...Read now
Unlock full access