Skip to content

Instantly share code, notes, and snippets.

@kayasax kayasax/parameters.ps1
Last active Jun 14, 2017

Embed
What would you like to do?
Exemple d'usage de PARAMETER
[CmdletBinding()] #make script react as cmdlet (-verbose etc..)
param(
[Parameter(Position=0, Mandatory=$true,ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[System.String]
$service,
[Parameter(Position=1)]
[System.string]
$computername="local"
)
Validation :
Param(
[ValidateSet(“Tom”,”Dick”,”Jane”)]
[String]
$Name
,
[ValidateRange(21,65)]
[Int]
$Age
,
[ValidateScript({Test-Path $_ -PathType ‘Container’})]
[string]
$Path
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.