-
-
Save danijeljw/1ed48da3b2acc7de09a406429b555d99 to your computer and use it in GitHub Desktop.
PowerShell Advanced function template
This file contains hidden or 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 Function-Name { | |
<# | |
.Synopsis | |
The short function description. | |
.Description | |
The long function description | |
.Example | |
C:\PS>Function-Name -param "Param Value" | |
This example does something | |
.Example | |
C:\PS> | |
You can have multiple examples | |
.Notes | |
Name: Function-Name | |
Author: Author Name | |
Last Edit: Date | |
Keywords: Any keywords | |
.Link | |
http://foo.com | |
http://twitter.com/foo | |
.Inputs | |
None | |
.Outputs | |
None | |
#Requires -Version 2.0 | |
#> | |
[CmdletBinding(SupportsShouldProcess=$True)] | |
Param | |
( | |
[Parameter(Mandatory=$true,HelpMessage="Enter a help message")] | |
[string]$param1, | |
[Parameter(Mandatory=$false)] | |
[switch]$param2 | |
) | |
PROCESS { | |
if ($pscmdlet.ShouldProcess("Continue?")) { | |
Write "Doing it..." | |
} | |
else { | |
Write "Not doing it..." | |
} | |
} | |
} #End function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment