Are you talking about a parameter defined with param , and arguments are available through $args ?
In general, a parameter is a variable that is part of a method signature (method declaration). An argument is an expression used when invoking a method.
But to differentiate param and args you can consider the former as defining parameters that can be passed to the script (or function, etc.) using the parameter name and its value (named argument) or positional arguments indicating only the values, and the latter - to access positional arguments over the parameters expected by the script, as defined in param
Consider the following script called test.ps1:
param($param1,$param2) write-host param1 is $param1 write-host param2 is $param2 write-host arg1 is $args[0] write-host arg2 is $args[1]
And suppose I call the script as follows:
.\test.ps1 1 2 3 4
I will get the output:
param1 is 1 param2 is 2 arg1 is 3 arg2 is 4
This is equivalent to its name as:
.\test.ps1 -param1 1 -param2 2 3 4
or even
.\test.ps1 3 4 -param2 2 -param1 1
source share