The script block is ended by entering the right curly brace ( } ) on a line by itself. Pressing Enter on the
blank last line ends function definition and writes it to memory. The command - line prompt then returns
to normal.
Windows PowerShell does some limited validation of a function definition entered from the command
line before it is saved to memory. Any code in the script block that would cause a processing error, such
as divide by zero, is brought to the user ??™ s attention and identified by the line and the character position
where the faulty code is located. If you make this type of mistake when entering a function from the
command line, the function is not saved to memory and the definition fails.
There is no validation for cmdlet elements entered as part of a function definition. For example, the
misspelling or misuse of a cmdlet or parameter name is only exposed when the function is run. Function
definitions can be changed by re - entering the definition at the command line.
Entering a function containing more than a few lines of code at the command line can be somewhat
frustrating; if you make any mistakes you have to start over. You may find it more useful to work out
and proof each individual element as a ??? stand alone ??? command before committing to their use together
in the script block.
Pages:
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101