PowerShell Parameters for Modules
One for the personal digital scrapbook. When writing PowerShell modules I always have to dig this up as reference material and I’ve added an example as well. about_Functions_Advanced_Parameters – https://technet.microsoft.com/en-us/library/hh847743.aspx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Function My-Function { param([parameter(Mandatory=$true)][string[]] $Computer, [string] $Username = "user", [string] $Password = 'password', [int] $Port = 443, [parameter(Mandatory=$true)] [ValidateSet( "Enable", "Disable" )] [string[]] $Status ) # Do stuff } |
Obviously you need...