Created
November 22, 2024 19:53
-
-
Save CN-CODEGOD/7057854cfe45cdd0b81b8b9ed7c78216 to your computer and use it in GitHub Desktop.
powershell 参数类型集合
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
| 1.parameterset | |
| nction Measure-Lines { | |
| [CmdletBinding(DefaultParameterSetName = 'Path')] | |
| param ( | |
| [Parameter(Mandatory, ParameterSetName = 'Path', Position = 0)] | |
| [Parameter(Mandatory, ParameterSetName = 'PathAll', Position = 0)] | |
| [string[]]$Path, | |
| [Parameter(Mandatory, ParameterSetName = 'LiteralPathAll', ValueFromPipeline)] | |
| [Parameter(Mandatory, ParameterSetName = 'LiteralPath', ValueFromPipeline)] | |
| [string[]]$LiteralPath, | |
| [Parameter(ParameterSetName = 'Path')] | |
| [Parameter(ParameterSetName = 'LiteralPath')] | |
| [switch]$Lines, | |
| [Parameter(ParameterSetName = 'Path')] | |
| [Parameter(ParameterSetName = 'LiteralPath')] | |
| [switch]$Words, | |
| [Parameter(ParameterSetName = 'Path')] | |
| [Parameter(ParameterSetName = 'LiteralPath')] | |
| [switch]$Characters, | |
| [Parameter(Mandatory, ParameterSetName = 'PathAll')] | |
| [Parameter(Mandatory, ParameterSetName = 'LiteralPathAll')] | |
| [switch]$All, | |
| [Parameter(ParameterSetName = 'Path')] | |
| [Parameter(ParameterSetName = 'PathAll')] | |
| [switch]$Recurse | |
| ) | |
| 2.validateset | |
| [ValidateSetAttribute("Steve")] | |
| [ValidateSetAttribute("Steve","Mary")] | |
| 3.$psscmdlet | |
| 常用: | |
| $psscmdlet.parametersetName | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment