Last active
October 15, 2019 14:49
-
-
Save manualbashing/8e3c2c659c77a712d424cbbdadefd6c0 to your computer and use it in GitHub Desktop.
ISE snipped for cmdlet with parameter validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .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