40 lines
1.1 KiB
PowerShell
40 lines
1.1 KiB
PowerShell
function Get-ConfigurationDataObjectPropertyValue {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory=$true)]
|
|
[AllowNull()]
|
|
$Value,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
[string]
|
|
$Property,
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[string]
|
|
$Path = ""
|
|
)
|
|
|
|
if([string]::IsNullOrWhiteSpace($Property)){
|
|
throw "Configuration data reference property must not be empty."
|
|
}
|
|
|
|
if($null -eq $Value){
|
|
throw "Configuration data reference property [$Property] was requested from a null value at path [$Path]."
|
|
}
|
|
|
|
if($Value -is [System.Collections.IDictionary]){
|
|
if(-not $Value.Contains($Property)){
|
|
throw "Configuration data reference property [$Property] was not found at path [$Path]."
|
|
}
|
|
|
|
return $Value[$Property]
|
|
}
|
|
|
|
$ObjectProperty = $Value.PSObject.Properties[$Property]
|
|
if($null -eq $ObjectProperty){
|
|
throw "Configuration data reference property [$Property] was not found at path [$Path]."
|
|
}
|
|
|
|
return $ObjectProperty.Value
|
|
}
|