I am new to powershell and trying to understand the Param block
, I have a simple program to get the two values and print it but when I run the below code, It asks for the input secondvalue
but skipped the first value
?
Why does it didn't ask for the firstvalue
as input?
function print {
Param(
[Parameter(mandatory = $true)] $firstvalue,
[Parameter(mandatory = $true)] $secondvalue
)
write-host first : $firstvalue
write-host second : $secondvalue
}
print($firstvalue, $secondvalue)
Sample Output :
./first.ps1
cmdlet print at command pipeline position 1
Supply values for the following parameters:
secondvalue: second data
first :
second : second data
Thanks, Any help is appreciated.