Functions/Types/New-CdsFetchExpression.ps1

<#
    .SYNOPSIS
    Return a fetch expression from fetch xml
#>

function New-CdsFetchExpression {
    [CmdletBinding()]
    [OutputType("Microsoft.Xrm.Sdk.Query.FetchExpression")]
    param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]   
        [String]
        $FetchXml
    )
    begin {  
        $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); 
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); 
    }    
    process {
        $fetchExpression = New-Object -TypeName "Microsoft.Xrm.Sdk.Query.FetchExpression" -ArgumentList $FetchXml;
        $fetchExpression;
    }
    end {
        $StopWatch.Stop();
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch;
    }
}

Export-ModuleMember -Function New-CdsFetchExpression -Alias *;