I've the following sample function
function Update-ExceptionPolicy {
[CmdletBinding()]
param(
[Parameter(ParameterSetName = 'WindowsFolderException')]
$folder,
[Parameter(ParameterSetName = 'WindowsFileException')]
$file,
$path,
[ValidateSet(
'WindowsFolderException',
'WindowsFileException'
)]
[string]
$ExceptionType
)
}
due to some external constraints, I'm trying to see if it's possible to design the function and ParameterSets based on the value of $ExceptionType via a ValidateSet list.
For example when trying to autocomplete the 2nd parameter I should either get "-file" or "-folder" based on the previous parameter value :
Update-ExceptionPolicy -ExceptionType WindowsFileException -<tab to autocomplete should show "-file">
Update-ExceptionPolicy -ExceptionType WindowsFolderException -<tab to autocomplete should show "-folder">
I've tried to have a look at dynamic parameters (this answer looked like an elegant solution even) but in my opinion it looks like a complex solution for a simple problem.
PS: I know I could also just split $ExceptionType into 2 switches but I don't want to do that because my project involves dozen of potentially complex parameter sets. Get it from the value could really be the best design here