Why do some of my parameters do not appear?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Why do some of my parameters do not appear?

Post by jvierra »

Not true. Look at this closely:
  1. function Move-ADUserOU
  2. {
  3.     [CmdletBinding(DefaultParameterSetName = 'username',
  4.                    SupportsShouldProcess = $true)]
  5.     [OutputType([switch], ParameterSetName = 'username')]
  6.     [OutputType([switch], ParameterSetName = 'csv')]
  7.     [OutputType([switch], ParameterSetName = 'textfile')]
  8.     param
  9.     (
  10.         [Parameter(ParameterSetName = 'textfile',
  11.                    Mandatory = $true,
  12.                    Position = 2)]
  13.         [string]$ou,
  14.         [Parameter(ParameterSetName = 'username',
  15.                    Mandatory = $true,
  16.                    ValueFromPipeline = $true,
  17.                    Position = 1)]
  18.         $name,
  19.         [Parameter(ParameterSetName = 'textfile',
  20.                    Mandatory = $false)]
  21.         $Description,
  22.         [Parameter(ParameterSetName = 'csv',
  23.                    ValueFromPipeline = $true)]
  24.         [Parameter(ParameterSetName = 'textfile')]
  25.         [string]$Filepath
  26.     )
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Why do some of my parameters do not appear?

Post by jvierra »

Can you please simplify this down to simple demonstration of where your issue is. This forum is not really designed to redesign large amounts of code. Just use the param statement and function wrapper and test without any of the other parts of the code. POst only one function and issue. This will make it easier to understand what you are having problems with.
User avatar
weiyen.tan@gmail.com
Posts: 55
Last visit: Fri Oct 27, 2023 10:59 pm

Re: Why do some of my parameters do not appear?

Post by weiyen.tan@gmail.com »

  1. [Parameter(ParameterSetName = 'textfile')]
  2.         [string]$Filepath
This one ?
User avatar
MikeFRobbins
Posts: 8
Last visit: Thu Apr 11, 2019 1:55 pm

Re: Why do some of my parameters do not appear?

Post by MikeFRobbins »

You do realize that you have two functions with the same name (Move-ADUserOU), correct? The parameters and help show up when I only use the one at the top, but the one at the bottom overrides the first one and does not contain the parameters or help that you're looking for.
Mike F Robbins
Microsoft MVP, SAPIEN MVP
User avatar
weiyen.tan@gmail.com
Posts: 55
Last visit: Fri Oct 27, 2023 10:59 pm

Re: Why do some of my parameters do not appear?

Post by weiyen.tan@gmail.com »

Thanks Mike I didnt even see the extra function... :roll:

I thought I had gone crazy...now everything is working as it should.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Why do some of my parameters do not appear?

Post by jvierra »

Mike s more patent then I am.

In the future it would help if you tried to reduce your issue to far fewer lines of code. Most forums are all volunteers and we don't want to spend a day on one issue.

If you had posted your script as a file I would have opened it in PowerShell studio directly - yes we can open the files right from the web site - and it would have been much easier to see the issues.
User avatar
weiyen.tan@gmail.com
Posts: 55
Last visit: Fri Oct 27, 2023 10:59 pm

Re: Why do some of my parameters do not appear?

Post by weiyen.tan@gmail.com »

Ok thanks jvierra,

Will post the entire script that is having the problem next time. Thank you for the help.
jvierra wrote:Mike s more patent then I am.

In the future it would help if you tried to reduce your issue to far fewer lines of code. Most forums are all volunteers and we don't want to spend a day on one issue.

If you had posted your script as a file I would have opened it in PowerShell studio directly - yes we can open the files right from the web site - and it would have been much easier to see the issues.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Why do some of my parameters do not appear?

Post by jvierra »

Will post the entire script that is having the problem next time. Thank you for the help.

-
Post ,it as a file attachment so we can open it. Pasting it does not make the script openable and it is too hard to read and copy when you have more than a few lines.

Also try to reduce issue to the fewest lines needed to demonstrate the problem. This is the norm for nearly all forums.

Glad you feel that it is fixed.
This topic is 8 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked