Functions/Converters/ConvertTo-CdsObjects.ps1

<#
    .SYNOPSIS
    Transform Entity Collection to custom object collection.
#>

function ConvertTo-CdsObjects {
    [CmdletBinding()]
    [OutputType([PsObject])]
    param
    (
        [Parameter(Mandatory, ValueFromPipeline)]
        [Microsoft.Xrm.Sdk.Entity[]]
        $InputObject
    )
    begin {          
        $records = @();

        $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); 
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); 
    }    
    process {
        $records += $InputObject | ConvertTo-CdsObject;
    }
    end {
        $records;

        $StopWatch.Stop();
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch;
    }
}

Export-ModuleMember -Function ConvertTo-CdsObjects -Alias *;