79087100

Date: 2024-10-14 17:20:27
Score: 1
Natty:
Report link

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

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: carrvo