Public/Get-FlattenedArray.ps1

Function Get-FlattenedArray {
    <#
        .SYNOPSIS
        Accepts an array and returns an flattened array with each property that was previously a nested array, converted to a string
         
        .PARAMETER Array
        Array of Data, usually users or computers from AD
 
        .OUTPUTS
        An array that has been flattened, so nested arrays are now strings, output-able to CSVs
 
        .EXAMPLE
        $Array
        Property1 : Value1
        Property2 : Value2
        Property3 : {ArrayData1, ArrayData2, ArrayData3, ArrayData4...}
 
        Get-FlattenedArray $Array
 
        Property1 : Value1
        Property2 : Value2
        Property3 : ArrayData1
                    ArrayData2
                    ArrayData3
                    ArrayData4
                    ArrayData5
                    ArrayData6
                    ArrayData7
                     
    #>

    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory,
            ValueFromPipeline)]
        $Array
    )
    begin {}
    process {
        $ArrayCopy = $Array
        $Properties = Get-NoteProperties $Array
        foreach ($Entry in $ArrayCopy) {
            foreach ($Property in $Properties) {
                If ($Entry.$Property -is [array]) {
                    $Entry.$Property = $Entry.$Property | Out-String
                }
            }
        }
        Return $ArrayCopy
    }
    end {}
}