I have a script that includes the following settings which returns an incorrect result if I use the mandatory parameter screen. It feels like it is failing to do some kind of type verification or casting on my input. How can I resolve it?
param ( [Parameter(Mandatory=$true)] [bool]$autoinstall )
if ( $autoinstall )
{
echo "Autoinstall true"
}
else
{
echo "Autoinstall false"
}
This works perfectly if I call it with .\myscript.ps1 -autoinstall $false but the $autoinstall variable is always true regardless of what I pass if I use the mandatory password prompt and enter '$false'.
EDIT:
Using a switch doesn't work for me. I really need to have this be both scriptable and the mandatory parameter function for user shortcuts for on the fly use.