PowerShell Parameters

One of the most useful features in Powershell is Parameters.
Microsoft has some excellent documentation on Powershell Parameters

Some of my favorites:

Default Parameter

[Switch]$Enabled = $True

Mandatory Parameter

[parameter(Mandatory=$true)]
[String]$Name

Validate Parameter Options in  a set

[ValidateSet("TCP", "UDP")]
[string]$NewPortType

Validate Parameter Options in a range (case INsensitive)

[ValidateRange(1,65535)]
[string]$NewPortNumber

Add Parameter Aliases

[alias("PortScope","Scope")]
[string] $NewPortScope

 

(Visited 247 times, 1 visits today)