kayasax
10/7/2013 - 12:44 PM

Exemple d'usage de PARAMETER

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 
    )