Files
Resolve-DSCConfigurationData/Private/Assert-ConfigurationDataParameterAllowedValue.ps1
Torsten Brendgen 4b83abc7f2 initial Commit
2026-06-27 00:36:04 +02:00

28 lines
693 B
PowerShell

function Assert-ConfigurationDataParameterAllowedValue {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[string]
$Name,
[Parameter(Mandatory=$true)]
$Definition,
[AllowNull()]
$Value
)
if(-not (Test-ConfigurationDataMapContainsKey -Map $Definition -Key "AllowedValues")){
return
}
$AllowedValues = @(Get-ConfigurationDataMapValue -Map $Definition -Key "AllowedValues")
if($AllowedValues.Count -eq 0){
return
}
if($AllowedValues -notcontains $Value){
throw "Parameter [$Name] value [$Value] is not allowed. Allowed values are: $($AllowedValues -join ', ')."
}
}