Skip to content

New-DynamicParam

SYNOPSIS

Creates a new dynamic parameter for a function.

SYNTAX

Return parameter (Default)

New-DynamicParam -Name <string> [-Alias <string[]>] [-Type <type>] [-ParameterSetName <string>]
 [-Mandatory] [-Position <int>] [-ValueFromPipeline] [-ValueFromPipelineByPropertyName]
 [-ValueFromRemainingArguments] [-HelpMessage <string>] [-Comment <string>]
 [-ValidateScript <scriptblock>] [-ValidatePattern <regex>]
 [-ValidatePatternOptions <RegexOptions[]>] [-ValidateCount <int[]>] [-ValidateRange <Object>]
 [-ValidateSet <Object>] [-ValidateLength <int[]>] [-ValidateNotNullOrEmpty]
 [-ValidationErrorMessage <string>] [-SupportsWildcards] [-AllowEmptyString] [-AllowNull]
 [-AllowEmptyCollection] [<CommonParameters>]

Add to dictionary

New-DynamicParam -Name <string> [-Alias <string[]>] [-Type <type>] [-ParameterSetName <string>]
 [-Mandatory] [-Position <int>] [-ValueFromPipeline] [-ValueFromPipelineByPropertyName]
 [-ValueFromRemainingArguments] [-HelpMessage <string>] [-Comment <string>]
 [-ValidateScript <scriptblock>] [-ValidatePattern <regex>]
 [-ValidatePatternOptions <RegexOptions[]>] [-ValidateCount <int[]>] [-ValidateRange <Object>]
 [-ValidateSet <Object>] [-ValidateLength <int[]>] [-ValidateNotNullOrEmpty]
 [-ValidationErrorMessage <string>] [-SupportsWildcards] [-AllowEmptyString] [-AllowNull]
 [-AllowEmptyCollection] [-DynamicParamDictionary <RuntimeDefinedParameterDictionary>]
 [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

Creates a new dynamic parameter for a function.

EXAMPLES

EXAMPLE 1

dynamicparam { $DynamicParamDictionary = New-DynamicParamDictionary $dynParam = @{ Name = 'GitignoreTemplate' Alias = 'gitignore_template' Type = [string] ValidateSet = Get-GitHubGitignoreList DynamicParamDictionary = $DynamicParamDictionary } New-DynamicParam @dynParam $dynParam2 = @{ Name = 'LicenseTemplate' Alias = 'license_template' Type = [string] ValidateSet = Get-GitHubLicenseList | Select-Object -ExpandProperty key DynamicParamDictionary = $DynamicParamDictionary } New-DynamicParam @dynParam2 return $DynamicParamDictionary }

PARAMETERS

-Alias

Specifies the aliases of the parameter.

Type: System.String[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-AllowEmptyCollection

Specifies if the parameter accepts empty collections.

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-AllowEmptyString

Specifies if the parameter accepts empty strings.

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-AllowNull

Specifies if the parameter accepts null values.

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Comment

Specifies the comments of the parameter.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-DynamicParamDictionary

Specifies the dynamic parameter dictionary.

Type: System.Management.Automation.RuntimeDefinedParameterDictionary
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Add to dictionary
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-HelpMessage

Specifies the help message of the parameter. Parameter Set specific

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Mandatory

Specifies if the parameter is mandatory. Parameter Set specific

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Name

Specifies the name of the parameter.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ParameterSetName

Specifies the parameter set name.

Type: System.String
DefaultValue: __AllParameterSets
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Position

Specifies the parameters positional binding. Parameter Set specific

Type: System.Int32
DefaultValue: 0
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-SupportsWildcards

Specifies if the parameter accepts wildcards.

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Type

Specifies the data type of the parameter.

Type: System.Type
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidateCount

Specifies the validate number of items for the parameter.

Type: System.Int32[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidateLength

Specifies the validate length of the parameter.

Type: System.Int32[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidateNotNullOrEmpty

Specifies if the parameter accepts null or empty values.

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidatePattern

Specifies the validate regular expression pattern of the parameter.

Type: System.Text.RegularExpressions.Regex
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidatePatternOptions

Specifies the validate regular expression pattern options of the parameter. For more info see RegexOptions.

Type: System.Text.RegularExpressions.RegexOptions[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidateRange

Specifies the validate range of the parameter.

Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidateScript

Specifies the validate script of the parameter.

Type: System.Management.Automation.ScriptBlock
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidateSet

Specifies the validate set of the parameter.

Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValidationErrorMessage

The custom error message pattern that is displayed to the user if validation fails. This parameter is not supported on Windows PowerShell Desktop Edition, if specified it will be ignored.

Examples of how to use this parameter: - ValidatePattern -> "The text '{0}' did not pass validation of the regular expression '{1}'". {0} is the value, {1} is the pattern. - ValidateSet -> "The item '{0}' is not part of the set '{1}'. {0} is the value, {1} is the set. - ValidateScript -> "The item '{0}' did not pass validation of script '{1}'". {0} is the value, {1} is the script.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValueFromPipeline

Specifies if the parameter accepts values from the pipeline. Parameter Set specific

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValueFromPipelineByPropertyName

Specifies if the parameter accepts values from the pipeline by property name. Parameter Set specific

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ValueFromRemainingArguments

Specifies if the parameter accepts values from the remaining command-line arguments that are not associated with another parameter. Parameter Set specific

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String

{{ Fill in the Description }}

System.String[]

{{ Fill in the Description }}

System.Type

{{ Fill in the Description }}

System.Management.Automation.SwitchParameter

{{ Fill in the Description }}

System.Int32

{{ Fill in the Description }}

System.Management.Automation.ScriptBlock

{{ Fill in the Description }}

System.Text.RegularExpressions.Regex

{{ Fill in the Description }}

System.Text.RegularExpressions.RegexOptions[]

{{ Fill in the Description }}

System.Int32[]

{{ Fill in the Description }}

System.Object

{{ Fill in the Description }}

OUTPUTS

[void]

{{ Fill in the Description }}

[System.Management.Automation.RuntimeDefinedParameterDictionary]

{{ Fill in the Description }}

System.Void

{{ Fill in the Description }}

System.Management.Automation.RuntimeDefinedParameter

{{ Fill in the Description }}

NOTES