Parameter-set error

ZM 206 Reputation points


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



this is my code

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


    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')]  

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

  2. Rich Matheisen 45,416 Reputation points

    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.


    0 comments No comments