Created
May 12, 2013 06:35
-
-
Save shane-edmonds/5562649 to your computer and use it in GitHub Desktop.
PowerShell Function Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function new-template { | |
<# | |
.SYNOPSIS | |
Brief description of what the function does | |
.DESCRIPTION | |
A better description | |
.NOTES | |
Function Name : new-template | |
Author : Adam Stone | |
Requires : PowerShell V2 | |
.LINK | |
http://adadmin.blogspot.com/ | |
.EXAMPLE | |
Simple usage | |
PS C:\> new-template -args values | |
.EXAMPLE | |
Simple usage | |
PS C:\> new-template -args values values etc | |
.PARAMETER first | |
A description of the first parameter | |
.PARAMETER targetdomain | |
A description of the sedond parameter | |
#> | |
#parameter validataion | |
param ( | |
#define the position of the parameter if required, specify if it is mandatory, and give a help message if anything is incorrect | |
[Parameter(Position=0, Mandatory=$true,HelpMessage="Enter the source Domain DNS name (eg domain.com) of the OU Structure")] | |
#add an alias to accept different names through the pipeline | |
[alias("other")] | |
#choose one of these if required | |
#make sure the option is not null or empty | |
#[validatenotnullorempty()] | |
#valadate the input against a regex pattern | |
#[validatepattern("regex")] | |
#valadate the input against defined set of attributes | |
#[validateset("one","two")] | |
#define type if necessary and what the default value will be if not manditory | |
[string] $first = "abcde" | |
, | |
#new parameter after the comma | |
[Parameter(Mandatory=$false)] | |
[alias("out")] | |
[string] $fileout = "none" | |
) | |
#the processes the function will complete | |
process { | |
#do stuff! | |
} | |
}#end function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment