Mandatory Parameters

suggest change

Parameters to a function can be marked as mandatory

function Get-Greeting{
    param
    (
        [Parameter(Mandatory=$true)]$name
    )
    "Hello World $name"
}

If the function is invoked without a value, the command line will prompt for the value:

$greeting = Get-Greeting 

cmdlet Get-Greeting at command pipeline position 1
Supply values for the following parameters:
name:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents