Steps to reproduce
Function New-ValidationDynamicParam
{
[CmdletBinding()]
[OutputType('System.Management.Automation.RuntimeDefinedParameter')]
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$Name,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory)]
[array]$ValidateSetOptions,
[Parameter()]
[switch]$Mandatory = $false,
[Parameter()]
[string]$ParameterSetName = '__AllParameterSets',
[Parameter()]
[switch]$ValueFromPipeline = $false,
[Parameter()]
[switch]$ValueFromPipelineByPropertyName = $false
)
$AttribColl = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
$ParamAttrib = New-Object System.Management.Automation.ParameterAttribute
$ParamAttrib.Mandatory = $Mandatory.IsPresent
$ParamAttrib.ParameterSetName = $ParameterSetName
$ParamAttrib.ValueFromPipeline = $ValueFromPipeline.IsPresent
$ParamAttrib.ValueFromPipelineByPropertyName = $ValueFromPipelineByPropertyName.IsPresent
$AttribColl.Add($ParamAttrib)
$AttribColl.Add((New-Object System.Management.Automation.ValidateSetAttribute($Param.ValidateSetOptions)))
$RuntimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter($Param.Name, [string], $AttribColl)
Return $RuntimeParam
}
Function DP-Bug
{
[CmdletBinding()]
Param
(
[ValidateSet("NoSpace","Yes Space")]
[string]$Param1
)
DynamicParam
{
$ParamOptions = @(
@{
'Name' = 'Param2';
'Mandatory' = $True;
'ValidateSetOptions' = @(
'Option 1',
'Option 2'
)
})
$RuntimeParamDic = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
foreach ($Param in $ParamOptions)
{
$RuntimeParam = New-ValidationDynamicParam @Param
$RuntimeParamDic.Add($Param.Name, $RuntimeParam)
}
Return $RuntimeParamDic
}
begin
{
Write-Output "OK"
}
}
DP-Bug -Param1 NoSpace -<tab>
DP-Bug -Param1 'Yes Space' -<tab>
Expected behavior
DP-Bug -Param1 NoSpace -Param2
DP-Bug -Param1 'Yes Space' -Param2
Actual behavior
DP-Bug -Param1 NoSpace -Param2
DP-Bug -Param1 'Yes Space' -Verbose
Basically, DynamicParam stops tab completing (though it does process and can become a mandatory parameter) if it is proceeded by a parameter value that has spaces/quotes around it. I tried changing the quotes from single to double as well, no change.
Environment data
Name Value
---- -----
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Reactions are currently unavailable
Steps to reproduce
Expected behavior
DP-Bug -Param1 NoSpace -Param2
DP-Bug -Param1 'Yes Space' -Param2
Actual behavior
DP-Bug -Param1 NoSpace -Param2
DP-Bug -Param1 'Yes Space' -Verbose
Basically, DynamicParam stops tab completing (though it does process and can become a mandatory parameter) if it is proceeded by a parameter value that has spaces/quotes around it. I tried changing the quotes from single to double as well, no change.
Environment data