Product: PowerShell Universal
Version: 3.4.5
Here is a sample of the parameters with the sets I am testing.
[CmdletBinding(DefaultParameterSetName='Server')]
param(
[Parameter(Mandatory)]
# [Parameter(Mandatory, ParameterSetName = 'Server')]
# [Parameter(Mandatory, ParameterSetName = 'Cluster')]
# [Parameter(Mandatory, ParameterSetName = 'Host')]
[string]
$Server,
[Parameter(Mandatory)]
# [Parameter(Mandatory, ParameterSetName = 'Server')]
# [Parameter(Mandatory, ParameterSetName = 'Cluster')]
# [Parameter(Mandatory, ParameterSetName = 'Host')]
[PSCredential]
$PSCredential,
[Parameter(Mandatory)]
# [Parameter(Mandatory, ParameterSetName = 'Server')]
# [Parameter(Mandatory, ParameterSetName = 'Cluster')]
# [Parameter(Mandatory, ParameterSetName = 'Host')]
[string]
$Region,
[Parameter(Mandatory, ParameterSetName = 'Cluster')]
[string]
$ClusterName,
[Parameter(Mandatory, ParameterSetName = 'Host')]
[string]
$HostName
)
$Server
Issue with the above code is when running from the admin ui , it does not pick up the default parameter set
Here is the code changes that allow the admin UI to work.
[CmdletBinding(DefaultParameterSetName='Server')]
param(
#[Parameter(Mandatory)]
[Parameter(Mandatory, ParameterSetName = 'Server')]
[Parameter(Mandatory, ParameterSetName = 'Cluster')]
[Parameter(Mandatory, ParameterSetName = 'Host')]
[string]
$Server,
# [Parameter(Mandatory)]
[Parameter(Mandatory, ParameterSetName = 'Server')]
[Parameter(Mandatory, ParameterSetName = 'Cluster')]
[Parameter(Mandatory, ParameterSetName = 'Host')]
[PSCredential]
$PSCredential,
# [Parameter(Mandatory)]
[Parameter(Mandatory, ParameterSetName = 'Server')]
[Parameter(Mandatory, ParameterSetName = 'Cluster')]
[Parameter(Mandatory, ParameterSetName = 'Host')]
[string]
$Region,
[Parameter(Mandatory, ParameterSetName = 'Cluster')]
[string]
$ClusterName,
[Parameter(Mandatory, ParameterSetName = 'Host')]
[string]
$HostName
)
$Server
Now I can pick each of the parameter set to run this script.
I see different issues with Invoke-PSUScript
The updated changes fail
Now I revert to the original version this happens
I changed from using the type [PSCredential] to [Object] , so it appears I cannot pass a [PSCredential] to a dynamic variable.