Templates/BasicStdTemplateWithArguments.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<#
.Synopsis Template .DESCRIPTION This template is stand alone and has argument parsing and support for -Whatif and whatnot. .PARAMETER arg1 First mandatory string argument. .PARAMETER arg2 Second optional string argument. .PARAMETER flag Switch parameter check with if ($flag:IsPresent) {} .Notes Author: Changes: #> [CmdletBinding(SupportsShouldProcess = $True)] param ( [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName=$true)] [string]$arg1, [string]$arg2, [switch]$flag ) #region Init $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition #endregion Msg "Start Execution" Write-Verbose "Script is in $scriptPath" if ($pscmdlet.ShouldProcess("ActiveCode", "Run Code")) { #Put your commands/code here... } Msg "End Execution" |