Problem with My Function’s Comments

by GuyThomas at 2013-04-05 05:57:53

Problem with My Function’s Comments
Question: What am I doing wrong?

This is how I produce the problem:
Get-Help Get-WmiClass –Full

What’s wrong:
Position = 1 [Should be zero]
No mention of Aliases See below

[quote]PARAMETERS
-Class <String>

Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false [/quote]

Bizarre Solutions
Adding this in the comments section <#
.Alias
#>
Even more bizarre solution adding
.x
Both solution produce the desired results: Position = 0, and Aliases

My question what am I doing to cause this behaviour?
[quote]PARAMETERS
-Class <string>

Required? false
Position? 0
Accept pipeline input? false
Parameter set name (All)
Aliases classic
Dynamic? false [/quote]
Here is the first half of my function.

[quote]Function Global:Get-WmiClass {
<#
.SYNOPSIS
A function to list WMI classes

.Description
Contains switches to filter for network WMI classes

.Example
Get-WMIClass -Network

#>
Param (
[Parameter(Mandatory=$False,
Position = 0 )]
[Alias(“classic”)]
[String]$Class ="",
[Switch]$Network
) [/quote]
by MasterOfTheHat at 2013-04-05 07:43:59
From the about_Function_Advanced_Parameters help page:
NOTE: When the Get-Help cmdlet displays the corresponding “Position?” parameter
attribute, the position value is incremented by 1. For example, a parameter
with a Position argument value of 0 has a parameter attribute of
"Position? 1."

So that answers the question about making it show up as “Position = 0” vs “Position = 1”. And I think that parameter aliases are not shown in Get-Help output…