Product: PowerShell Universal
Version: 3.8.12
I’ve run into a potential bug when trying to use Invoke-PSUScript within an Endpoint when calling a script that uses parameter sets. Having a single parameter set per parameter does not give any errors, example:
PARAM(
[Parameter(Mandatory, ParameterSetName = "Set1")]
[string]$Test1
)
But when I add an additional parameter set to the same parameter, like this:
PARAM(
[Parameter(Mandatory, ParameterSetName = "Set1")]
[Parameter(Mandatory, ParameterSetName = "Set2")]
[string]$Test1
)
I receive an error in the Endpoint stating: Cannot retrieve the dynamic parameters for the cmdlet. An item with the same key has already been added. Key: Test1
My assumption is that when generating the dynamic parameters, it tries to add the same parameter name for each parameter set it has assigned. Is there a workaround for this other than refactoring the underlying script to not use parameter sets?