Two parameters $installDatabase and $databasePassword:
[Parameter(ParameterSetName='Test', mandatory=$false)][Switch]$installDatabase,
[Parameter(ParameterSetName='Test')][String]$databasePassword
I need this to perform the same functionality as this if:
if ($installDatabase -and !($databasePassword) -or ($databasePassword -and !($installDatabase)))
{
Write-Verbose "Use -installDatabase and -databasePassword together."
}
What is wrong with the ParameterSet?
Edit: OK here is a version where the parameter set is evaluated
function test
{
[CmdletBinding(DefaultParameterSetName="Test")]
param(
[Parameter(ParameterSetName='Test', mandatory=$true)]
[switch]$installDatabase,
[Parameter(ParameterSetName='Test2', mandatory=$true)]
[String]$databasePassword
)
}
In this version either you call test -installDatabase or test -databasePassword pwd
or the following exception occurs:
test : Parameter set cannot be resolved using the specified named parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With