Private/Copy-InfraPulseValue.ps1

function Copy-InfraPulseValue {
    [CmdletBinding()]
    param(
        [AllowNull()]
        [object]$Value
    )

    if ($null -eq $Value) {
        return $null
    }

    if ($Value -is [System.Collections.IDictionary]) {
        $copy = [ordered]@{}
        foreach ($key in $Value.Keys) {
            $copy[$key] = Copy-InfraPulseValue -Value $Value[$key]
        }
        return , $copy
    }

    if (($Value -is [System.Collections.IEnumerable]) -and -not ($Value -is [string])) {
        $items = New-Object System.Collections.Generic.List[object]
        foreach ($item in $Value) {
            [void]$items.Add((Copy-InfraPulseValue -Value $item))
        }
        return , $items.ToArray()
    }

    return $Value
}