Created
January 14, 2020 21:26
-
-
Save mwallner/f503666bd9ea480a3bef80318fe5be3e to your computer and use it in GitHub Desktop.
powershell cmdet vs basic function argument handling
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 Get-EvilCmdLet { | |
[CmdletBinding()] | |
param( | |
[ValidateSet('A', 'B')] | |
$Category | |
) | |
Write-Output "= Get-EvilCmdLet =" | |
Write-Output "* PSBoundParameters" | |
$PSBoundParameters.Keys | % { | |
Write-Output " ** $_ -> $($PSBoundParameters[$_])" | |
} | |
Write-Output "* args" | |
$args | % { | |
Write-Output " ** $_" | |
} | |
} | |
function Get-EvilBasic { | |
param( | |
$Category | |
) | |
Write-Output "= Get-EvilBasic =" | |
Write-Output "* PSBoundParameters" | |
$PSBoundParameters.Keys | % { | |
Write-Output " ** $_ -> $($PSBoundParameters[$_])" | |
} | |
Write-Output "* args" | |
$args | % { | |
Write-Output " ** $_" | |
} | |
} | |
Get-EvilBasic "A" -foo bar -verbose | |
Get-EvilCmdLet "B" -foo bar -verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment