Files
Resolve-DSCConfigurationData/Private/Resolve-ConfigurationDataValue.ps1

51 lines
1.4 KiB
PowerShell

function Resolve-ConfigurationDataValue {
[CmdletBinding()]
Param(
[AllowNull()]
$Value,
[Parameter(Mandatory=$true)]
$Context
)
if($null -eq $Value){
return $null
}
if($Value -is [System.Collections.Specialized.OrderedDictionary]){
$Resolved = [ordered]@{}
foreach($Entry in $Value.GetEnumerator()){
if($Entry.Name -eq "Sealed"){
continue
}
$Resolved[$Entry.Name] = Resolve-ConfigurationDataValue -Value $Entry.Value -Context $Context
}
return $Resolved
}
if($Value -is [System.Collections.Hashtable]){
$Resolved = @{}
foreach($Entry in $Value.GetEnumerator()){
if($Entry.Name -eq "Sealed"){
continue
}
$Resolved[$Entry.Name] = Resolve-ConfigurationDataValue -Value $Entry.Value -Context $Context
}
return $Resolved
}
if($Value -is [System.Array] -and $Value -isnot [string]){
$Resolved = @()
foreach($Item in $Value){
$Resolved += ,(Resolve-ConfigurationDataValue -Value $Item -Context $Context)
}
return ,$Resolved
}
if($Value -is [string] -and (Test-ConfigurationDataExpression -Value $Value)){
return Resolve-ConfigurationDataExpression -Expression $Value -Context $Context
}
return $Value
}