Skip to content

Instantly share code, notes, and snippets.

@manualbashing
Last active October 15, 2019 14:49
Show Gist options
  • Select an option

  • Save manualbashing/8e3c2c659c77a712d424cbbdadefd6c0 to your computer and use it in GitHub Desktop.

Select an option

Save manualbashing/8e3c2c659c77a712d424cbbdadefd6c0 to your computer and use it in GitHub Desktop.
ISE snipped for cmdlet with parameter validation.
<#
.Synopsis
Kurzbeschreibung
.DESCRIPTION
Lange Beschreibung
.EXAMPLE
Beispiel für die Verwendung dieses Cmdlets
.EXAMPLE
Another example of how to use this cmdlet
.INPUTS
Inputs to this cmdlet (if any)
.OUTPUTS
Output from this cmdlet (if any)
.NOTES
Allgemeine Hinweise
.COMPONENT
The component this cmdlet belongs to
.ROLE
The role this cmdlet belongs to
.FUNCTIONALITY
The functionality that best describes this cmdlet
#>
function Verb-Noun
{
[CmdletBinding(DefaultParameterSetName='Parameter Set 1',
SupportsShouldProcess=$true,
PositionalBinding=$false,
HelpUri = 'http://www.microsoft.com/',
ConfirmImpact='Medium')]
[Alias()]
[OutputType([String])]
Param
(
# Hilfebeschreibung zu Param1
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
ValueFromRemainingArguments=$false,
Position=0,
ParameterSetName='Parameter Set 1')]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[ValidateCount(0,5)]
[ValidateSet("sun", "moon", "earth")]
[ValidateScript({ (Test-Path -Path $_) -notcontains $false })]
[Alias("p1")]
$Param1,
# Hilfebeschreibung zu Param2
[Parameter(ParameterSetName='Parameter Set 1')]
[AllowNull()]
[AllowEmptyCollection()]
[AllowEmptyString()]
[ValidateScript({$true})]
[ValidateRange(0,5)]
[int]
$Param2,
# Hilfebeschreibung zu Param3
[Parameter(ParameterSetName='Another Parameter Set')]
[ValidatePattern("[a-z]*")]
[ValidateLength(0,15)]
[String]
$Param3
)
Begin
{
}
Process
{
if ($pscmdlet.ShouldProcess("Target", "Operation"))
{
}
}
End
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment