first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

PowerShell: “calling a function with parameters”; Serge van den Oever

I just started with PowerShell to do some complex scripting. As a beginner in this new language I will probably run into all the quirks that the language has, but hey thats the fun with learning something new. The first quirk: calling a function with parameters.

function f([string]$a, [string]$b)
{
    Write-Host "a:", $a, " b:", $b
}

f("hello", "world") # Results in: a: hello world b:
f "hello" "world" # Results in a: hello b: world

If you put something between parentheses, it is executed as an expression first.

For more information on what you can do with functions, execute the following command in your PowerShell: Get-Help about_function

[http://weblogs.asp.net/soever/archive/2006/11/29/ powershell-calling-a-function-with-parameters.aspx]

mod date: 2009-03-27T01:18:31.000Z