Skip to content

Instantly share code, notes, and snippets.

@kayasax
Last active June 14, 2017 11:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kayasax/6867281 to your computer and use it in GitHub Desktop.
Save kayasax/6867281 to your computer and use it in GitHub Desktop.
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