Changes

Jump to: navigation, search

Windows PowerShell 1.0 Functions

1 byte added, 20:44, 4 December 2008
Passing Parameters to a Function
== Passing Parameters to a Function ==
In the preceding example, the function did not expect to be passed any parameters (also known as arguments). These are values which are entered on the command-line along with the function at the point that it is called. Windows PowerShell stores any parameters that were entered in a special variable called ''$args''. The ''$args'' variable is actually an array object with each parameter assigned to an array element (for more detailed information on working with arrays refer to the chapter entitled [[Working with Arrays in Windows PowerShell 1.0]]).
In order to demonstrate the use of the ''$args'' variable in the context of Windows PowerShell functions, the following function displays the number of parameters passed into the function, and then multiplies the first two parameters:

Navigation menu