Why do some of my parameters do not appear?

Ask your Windows 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.
jvierra
Posts: 14145
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Wed Feb 24, 2016 1:44 pm

Not true. Look at this closely:
  1. function Move-ADUserOU
  2.  
  3. {
  4.  
  5.     [CmdletBinding(DefaultParameterSetName = 'username',
  6.  
  7.                    SupportsShouldProcess = $true)]
  8.  
  9.     [OutputType([switch], ParameterSetName = 'username')]
  10.  
  11.     [OutputType([switch], ParameterSetName = 'csv')]
  12.  
  13.     [OutputType([switch], ParameterSetName = 'textfile')]
  14.  
  15.     param
  16.  
  17.     (
  18.  
  19.         [Parameter(ParameterSetName = 'textfile',
  20.  
  21.                    Mandatory = $true,
  22.  
  23.                    Position = 2)]
  24.  
  25.         [string]$ou,
  26.  
  27.         [Parameter(ParameterSetName = 'username',
  28.  
  29.                    Mandatory = $true,
  30.  
  31.                    ValueFromPipeline = $true,
  32.  
  33.                    Position = 1)]
  34.  
  35.         $name,
  36.  
  37.         [Parameter(ParameterSetName = 'textfile',
  38.  
  39.                    Mandatory = $false)]
  40.  
  41.         $Description,
  42.  
  43.         [Parameter(ParameterSetName = 'csv',
  44.  
  45.                    ValueFromPipeline = $true)]
  46.  
  47.         [Parameter(ParameterSetName = 'textfile')]
  48.  
  49.         [string]$Filepath
  50.  
  51.     )

jvierra
Posts: 14145
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Wed Feb 24, 2016 1:57 pm

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
Joined: Wed Apr 09, 2014 2:06 am

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

Post by weiyen.tan@gmail.com » Wed Feb 24, 2016 2:16 pm

  1. [Parameter(ParameterSetName = 'textfile')]
  2.  
  3.         [string]$Filepath
This one ?

User avatar
MikeFRobbins
Posts: 8
Joined: Sun Mar 03, 2013 12:45 pm
Contact:

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

Post by MikeFRobbins » Wed Feb 24, 2016 3:22 pm

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
Joined: Wed Apr 09, 2014 2:06 am

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

Post by weiyen.tan@gmail.com » Wed Feb 24, 2016 4:16 pm

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: 14145
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Wed Feb 24, 2016 4:33 pm

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
Joined: Wed Apr 09, 2014 2:06 am

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

Post by weiyen.tan@gmail.com » Wed Feb 24, 2016 4:47 pm

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: 14145
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Wed Feb 24, 2016 5:14 pm

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.

Locked