Skip to content

Instantly share code, notes, and snippets.

@gerane
Created July 1, 2016 17:18
Show Gist options
  • Save gerane/10c286bdbff1b8ce72578ed7b40fdc3b to your computer and use it in GitHub Desktop.
Save gerane/10c286bdbff1b8ce72578ed7b40fdc3b to your computer and use it in GitHub Desktop.
Just adding <# #> allows Get-Help to see the parameter attribute help. Removing <# #> breaks Help even if the parameter attributes are present.
function Test-WildCardsWorks
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true,
Position=0,
ParameterSetName="Path",
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage="Path to one or more locations.")]
[SupportsWildcards()]
[PSDefaultValue(Help='*')]
[ValidateNotNullOrEmpty()]
[string[]]$Path = '*',
[Parameter(Mandatory=$false, Position=1)]
[SupportsWildCards()]
[PSDefaultValue(Help='*')]
[String[]]$Name ="*"
)
Begin
{
}
Process
{
$path | Where-Object { $_.Fullname -like 'test' }
}
End
{
}
}
NAME
Test-WildCardsFails
SYNTAX
Test-WildCardsFails [-Path] <string[]> [[-Name] <string[]>] [<CommonParameters>]
PARAMETERS
-Name <string[]>
Required? false
Position? 1
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
-Path <string[]>
Path to one or more locations.
Required? true
Position? 0
Accept pipeline input? true (ByValue, ByPropertyName)
Parameter set name Path
Aliases None
Dynamic? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String[]
OUTPUTS
System.Object
ALIASES
None
REMARKS
None
function Test-WildCardsWorks
{
<#
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true,
Position=0,
ParameterSetName="Path",
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage="Path to one or more locations.")]
[SupportsWildcards()]
[PSDefaultValue(Help='*')]
[ValidateNotNullOrEmpty()]
[string[]]$Path = '*',
[Parameter(Mandatory=$false, Position=1)]
[SupportsWildCards()]
[PSDefaultValue(Help='*')]
[String[]]$Name ="*"
)
Begin
{
}
Process
{
$path | Where-Object { $_.Fullname -like 'test' }
}
End
{
}
}
NAME
Test-WildCardsWorks
SYNTAX
Test-WildCardsWorks [-Path] <string[]> [[-Name] <string[]>] [<CommonParameters>]
PARAMETERS
-Name <string[]>
Required? false
Position? 1
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
-Path <string[]>
Path to one or more locations.
Required? true
Position? 0
Accept pipeline input? true (ByValue, ByPropertyName)
Parameter set name Path
Aliases None
Dynamic? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String[]
OUTPUTS
System.Object
ALIASES
None
REMARKS
None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment