49 lines
1.6 KiB
PowerShell
49 lines
1.6 KiB
PowerShell
[CmdletBinding(DefaultParameterSetName = 'Set1')]
|
|
param (
|
|
# Mandatory string with alias and validation, positional
|
|
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'Set1')]
|
|
[Parameter(Position = 2, Mandatory = $false, ParameterSetName = 'Set2')]
|
|
[Alias('n')]
|
|
[ValidateNotNullOrEmpty()]
|
|
[ValidateScript({
|
|
$_ -notlike 'undefined'
|
|
})]
|
|
[string]$Name,
|
|
|
|
# Optional int with default value, validated range
|
|
[Parameter(ParameterSetName = 'Set1')]
|
|
[ValidateRange(1, 100)]
|
|
[int]$Count = 10,
|
|
|
|
# Switch parameter
|
|
[Parameter(ParameterSetName = 'Set1')]
|
|
[switch]$VerboseMode,
|
|
|
|
# Accepts pipeline input by value
|
|
[Parameter(ValueFromPipeline = $true, ParameterSetName = 'Set2')]
|
|
[string]$InputObject,
|
|
|
|
# Accepts pipeline input by property name
|
|
[Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Set2')]
|
|
[string]$Property,
|
|
|
|
# Parameter that takes an array
|
|
[Parameter(ParameterSetName = 'Set1')]
|
|
[string[]]$Tags,
|
|
|
|
# Optional parameter with script block default
|
|
[Parameter(ParameterSetName = 'Set1')]
|
|
[datetime]$StartTime = (Get-Date),
|
|
|
|
# Mandatory parameter in a different parameter set
|
|
[Parameter(Mandatory = $true, ParameterSetName = 'Set3')]
|
|
[ValidateSet('Low', 'Medium', 'High')]
|
|
[string]$Priority,
|
|
|
|
# Nullable type
|
|
[Parameter(ParameterSetName = 'Set1')]
|
|
[Nullable[bool]]$IsEnabled
|
|
)
|
|
|
|
process {}
|