You want to use Parameter Sets. You can think of them like C# overloaded functions.
[Cmdlet(...)]
public sealed class MyExample : Cmdlet
{
[Parameter(Mandatory = true, ParameterSetName = "only parameter A")]
public string ParameterA { get; set; }
[Parameter(Mandatory = true, ParameterSetName = "only parameter B")]
public string ParameterB { get; set; }
}
Just found this for the first time as another resource! https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/cmdlet-parameter-sets?view=powershell-7.4