Last active
July 9, 2018 11:54
-
-
Save gp42/62f642b7a46c91900d392f4bf4f028f0 to your computer and use it in GitHub Desktop.
CmdletBinding - makes a function work like a compiled cmdlet.
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
# The CmdletBinding attribute is an attribute of functions that makes them operate | |
# like compiled cmdlets that are written in C#, and it provides access to features of cmdlets. | |
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_cmdletbindingattribute?view=powershell-6 | |
[CmdletBinding()] | |
param( | |
# Input params | |
[string]${inputParam}, | |
# Example with validator and help message | |
[Parameter(HelpMessage="Output directory")] | |
[ValidateScript({$_ -notmatch "\.exe$"})] | |
[string]${outputDir} = 'out', | |
# Environment Variable usage | |
[string] $param = $env:PARAM, | |
# Switch param | |
[switch] $someFlag | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment