Search notes:

PowerShell: the automatic variable $args

$args is an array that is used:

Undeclared function parameters

$args is populated in functions for undeclared parameters.
function fOne {
   write-host "`$args.length = $($args.length)"
}

function fTwo($p1, $p2) {
   write-host "`$args.length = $($args.length)"
}

fOne
#
#  $args.length = 0

fOne foo
#
#  $args.length = 1

fOne bar baz
#
#  $args.length = 2

fTwo 42 'hello world'
#
#  $args.length = 0

fTwo A B excess parameters
#
#  $args.length = 2
Github repository about-PowerShell, path: /language/variable/automatic/args/parameters.ps1

See also

Some investigations on passing arrays as arguments to executables and PowerShells scripts.
The influence of System.Management.Automation.CmdletBindingAttribute
Other automatic variables (especially $input.

Index