private/Functions/New-DynamicParameterSet.ps1
Function New-DynamicParameterSet { [cmdletBinding( #SupportsShouldProcess = $true, #ConfirmImpact='high' )] Param( [Parameter( Mandatory=$true )] [hashtable]$ParameterTable ) $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary ForEach ($entry in $ParameterTable.Keys) { $Param = @{ Name = $entry Enum = $ParameterTable[$entry].Enum } if($ParameterTable[$entry].containsKey('Mandatory')) { $Param.Add('Mandatory',$ParameterTable[$entry].Mandatory) } if($ParameterTable[$entry].containsKey('Position')) { $Param.Add('Position',$ParameterTable[$entry].Position) } if($ParameterTable[$entry].containsKey('ParameterSetName')) { $Param.Add('ParameterSetName',$ParameterTable[$entry].ParameterSetName) } if($ParameterTable[$entry].containsKey('DefaultValue')) { $Param.Add('DefaultValue',$ParameterTable[$entry].DefaultValue) } $RuntimeParameter = New-DynamicParameter @Param $RuntimeParameterDictionary.Add($entry, $RuntimeParameter) } return $RuntimeParameterDictionary } |