[Solved] AmbiguousParameterSet error

You get the following error:

  • CategoryInfo          : InvalidArgument: (:) [], ParameterBindingException
  • FullyQualifiedErrorId : AmbiguousParameterSet,

The reason

You have this error in two situations:

  • Your command-line uses simultaneously two or more parameters members of different exclusive parameter sets.
  • Your command-line doesn’t use any of the parameters members of a parameter set.

  • Let’s illustrate your error

    Example 1

    Restart-Computer parameter sets

    There are two sets of parameters.
    In green you have parameters which are members of both parameter sets A and B.
    You can use any of those green parameters whenever you want.

    In blue you have parameters which are exclusively members of parameter set A.
    In orange you have parameters which are exclusively members of parameter set B.
    If you use at least one parameter of set A, you can’t use any parameter of set B, and conversely.
    For instance, if you use the AsJob parameter, you cannot use the Timeout parameter.

    However, you are not obliged to use any of the exclusive parameters.
    If you use a green parameter, it is sufficient to meet the parameterset rules.

    Example 2

    Restart-Computer parameter sets

    There are still two sets of parameters.
    But, in green you have parameters which are not member of any parameter set.
    You can use any of those green parameters whenever you want.

    In blue you have parameters which are exclusively members of parameter set A.
    In orange you have parameters which are exclusively members of parameter set B.
    Like in our first example, if you use at least one parameter of set A, you can’t use any parameter of set B, and conversely.
    However, unlike in our first example, you have to use at least one parameter of any of any parameter sets.
    This means for example using the AsJob parameter or the Timeout parameter.

    More about

    About Functions Advanced Parameters (Microsoft Docs)

    Cmdlet Parameter Sets (MSDN)

    Leave a Reply

    Please log in using one of these methods to post your comment:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s