Last active
July 21, 2017 16:35
-
-
Save notesbytom/e8d9661d6e202dff9d5f9ff70045351b to your computer and use it in GitHub Desktop.
Mandatory Named Parameters for PowerShell Script File
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
# comment allowed before script param() statement | |
param([Parameter(Mandatory=$true)] $a, $b) | |
$ErrorActionPreference = "Stop" | |
Set-StrictMode -Version Latest | |
"`$a = $a, `$b = $b" | |
$args | |
$MyInvocation | |
$PSBoundParameters | |
Exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Require a parameter for PowerShell script file. I believe the param() statement must be the first real statement in the file other than comments.
Typical statements like setting Error Action Preference and Strict Mode must come AFTER the "script" level param() statement.