PowerShell Parameter Sets: Require either A or B to be set

Viewed 8026

Is there a simple way to have a parameter set that allows either A or B but not both to be specified?

E.G. My script will either accept:

.\SimpleScript.ps1 -A "str1" -X 1 -Y 2 -Z 3

or

.\SimpleScript.ps1 -B "str2" -X 1 -Y 2 -Z 3

but not:

.\SimpleScript.ps1 -A "str1" -B "str2" -X 1 -Y 2 -Z 3
2 Answers
Related