Parameter-set error

ZM 206 Reputation points
2022-11-09T17:53:57.193+00:00

Hi,

this is the error that i got on one of my runs

258778-screenshot-2022-11-09-175123.png

&

this is my code
258790-screenshot-2022-11-09-175030.png

how can i solve that issue? i thought about removing the mandatory true part?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,431 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Justin Brickley 1 Reputation point
    2022-11-09T19:01:36.44+00:00

    Hi,

    When running a function, it is worth noting that only 1 parameter set can be matched at a time.

    In this case, it likely means that you either have two switches enabled at once, or "personalName" defined while you also have the backup switch enabled at the same time.
    If you would like "personalName" to exist within the "Back" parameter set, you will need to add another Parameter declaration stating that it exists within that set.
    This would look something like this:

    [Parameter(Mandatory=$true, ParameterSetName = 'Delete')]  
    [Parameter(Mandatory=$true, ParameterSetName = 'BackAndDelete')]  
    [Parameter(Mandatory=$true, ParameterSetName = 'Back')]  
    [string]  
    $personalName  
    

    Please let me know if this works, or if you have any additional questions!


  2. Rich Matheisen 45,416 Reputation points
    2022-11-10T23:48:21.657+00:00

    I think all you need to do is to remove two of the "[Parameter(...)]" specifications for the "targetname" parameter and remove the ",ParameteSetName=..." from the third. The targetname is part of every other parameter set so there's no need to make it a member of any of them.

    259311-psets.jpg

    0 comments No comments