Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7171409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:24:33+00:00 2026-05-28T15:24:33+00:00

I have a powershell cmdlet, and I can’t seem to get the parameter sets

  • 0

I have a powershell cmdlet, and I can’t seem to get the parameter sets to work.
This cmdlet has 31 possible parameters and it can go down two possible processing paths.
All 31 parameters are optional, 18 are common to both paths, 9 are unique to the “right” path and 4 are unique to the “left” path. What I’m trying to accomplish is to use powershell’s ParameterSet attributes to specify which parameter can be used when. But it’s not working.

Below is a mock-up of my attempt. Names have been changed to protect the innocent.

[Parameter]
public string SomeString1 { get; set; }

[Parameter]
public string SomeString2 { get; set; }

[Parameter(ParameterSetName = "left")]
public string LeftName { get; set; }

[Parameter(ParameterSetName = "left")]
public string LeftDomain { get; set; }

[Parameter(ParameterSetName = "right")]
public string RightID { get; set; }

[Parameter(ParameterSetName = "right")]
public string RightIP { get; set; }

So when I run this, I try to check my parameter lists using get-help, and all I see is one big clump of parameters when it should split them up into two lists, one including the two “left” parameters plus the two unnamed ones, and another including the “right” parameters plus the unnamed ones.

The hilarious part is that we have another cmdlet that lets me do this just fine, no problems, perfect output. But for some reason this one isn’t letting me. Same includes, same syntax, just different names. So I know our setup is correct, because it works sometimes. But it doesn’t work all of the time, so I’m stumped.

I’ve tried changing some/all of the parameters to Mandatory, I’ve tried using a DefaultParameterSetName at the header. I’ve tried doubling up on sets, like including a set named “both” and making every parameter part of that set. I’ve read through the MSDN article on parameter sets, I’ve read through the first 40 articles that google returns, but I can’t get it working. Half of my team has stood behind my desk watching me do it, and they’re all stumped as well.

What can I do to:

  • figure out why it isn’t recognizing my parameter sets
  • make it so that it does
  • prevent this from happening in the future
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:24:33+00:00Added an answer on May 28, 2026 at 3:24 pm

    Keith Hill, thanks for the tip – I tried commenting out all but the most minimal parameters and I noticed that when I ran the get-help on the cmdlet that it still returned all of the parameters. I knew something goofy was going on, and it turns out that the help file was not getting updated when I compiled the cmdlet.

    When I worked that issue out, it appears that everything was functioning exactly as I expected it to, it was that the get-help was using old information. That’s why nobody else could figure it out, either. I was doing it right, so there were no bugs, just poor documentation.

    Major facepalm moment, but I got it worked out. The lesson is: always make sure your help is automatically generating.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In PowerShell you can use the Get-WmiObject cmdlet to grab WMI classes. I have
I have a PowerShell script cmdlet that supports the -WhatIf & -Confirm parameters. It
In PowerShell 1.0, if I have a cmdlet parameter of an enum type, what
I have an application that has Powershell 1 embedded into it, but we need
I have an assembly that contains cmdlets. Can Powershell enumerate the cmdlets available in
What's the best way to get the current PowerShell Cmdlet from another object? If
I have a PowerShell script that calls a CmdLet which in turn reports its
I have a powershell script (below) which seems to work but prints an error
I have this PowerShell command to add members to a Distributon Group in Exchange
I'm pretty new to powershell. I've built a custom cmdlet. I already have it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.