cdtech1980
MIS
Hi I am using a parameter called foo which I set to mandatory=$false. This means it is not required. In my script I would like to test if it exists or not and do something if it does.
For example if someone runs .\myscripts.ps1 -FOO valueisgiven the scripts will do something if not just ignore. Should I do something like if ($FOO -ne "NULL") { do something} else .....
Thank you.
For example if someone runs .\myscripts.ps1 -FOO valueisgiven the scripts will do something if not just ignore. Should I do something like if ($FOO -ne "NULL") { do something} else .....
Thank you.
Code:
[Parameter(Mandatory=$false,Position=3)]
[String]
$FOO
Code:
if ($FOO -ne "NULL")
{
[indent]do sometthing[/indent]
}
else {
[indent]do something else[/indent]
}[/indent]