Functions/Client/Invoke-CdsRequest.ps1
<#
.SYNOPSIS Execute Organization Request. #> function Invoke-CdsRequest { [CmdletBinding()] [OutputType([Microsoft.Xrm.Sdk.OrganizationResponse])] param ( [Parameter(Mandatory=$false, ValueFromPipeline)] [Microsoft.Xrm.Tooling.Connector.CrmServiceClient] $CdsClient = $Global:CdsClient, [Parameter(Mandatory=$true)] [Microsoft.Xrm.Sdk.OrganizationRequest] $Request ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $response = Protect-CdsCommand -ScriptBlock { $CdsClient.Execute($Request) }; $response; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Invoke-CdsRequest -Alias *; |