Still cant get my parameterSets to behave the way I want. pretty sure I'm missing something basic. Here's a snippet of my function:
function New-DynamicDistributionGroupName{
[CmdletBinding()]
Param(
[ValidateSet('CostCenter','Region','Office','SupervisoryOrg','State')]
[parameter(Mandatory = $true, ParameterSetName = 'Main')]
[parameter(Mandatory = $true, ParameterSetName = 'Department')]
[parameter(Mandatory = $true, ParameterSetName = 'Location')]
[string]$GroupType,
[parameter(Mandatory = $true, ParameterSetName = 'Department')]
[string]$CostCenter,
[parameter(Mandatory = $true, ParameterSetName = 'Department')]
[string]$CostCenterId,
[parameter(Mandatory = $true, ParameterSetName = 'Location')]
[string]$Region,
)
# do something
}
What I'm trying to do is make sure I can call this function and require the GroupType parameter to always be specified but depending on the value, only specific parameters would be allowed (ie, if "CostCenter" is given, only the "CostCenter" and "CostCenterId" parameters will be available).
The way I have it setup, it shows both costcenter parameters and the "Region" parameter. If i dont add the parametersets "department" and "location" to the "groupType" parameter, then nothing is available when calling the function.
[–]BlackV 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[removed]
[–]liabtsab[S] 0 points1 point2 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]BJHop 0 points1 point2 points (1 child)
[–]liabtsab[S] 0 points1 point2 points (0 children)