强制参数
函数的参数可以标记为必需参数
function Get-Greeting{
param
(
[Parameter(Mandatory=$true)]$name
)
"Hello World $name"
}
如果在没有值的情况下调用该函数,命令行将提示输入值:
$greeting = Get-Greeting
cmdlet Get-Greeting at command pipeline position 1
Supply values for the following parameters:
name: