Functions/Client/Update-CdsRecord.ps1

<#
    .SYNOPSIS
    Update entity record in CRM.
#>

function Update-CdsRecord {
    [CmdletBinding()]
    param
    (    
        [Parameter(Mandatory=$false, ValueFromPipeline)]
        [Microsoft.Xrm.Tooling.Connector.CrmServiceClient]
        $CdsClient = $Global:CdsClient,

        [Parameter(Mandatory=$true, ValueFromPipeline)]
        [Microsoft.Xrm.Sdk.Entity]
        $Record,

        [Parameter(Mandatory=$false)]
        [switch]
        $BypassCustomPluginExecution = $false
    )
    begin {   
        $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); 
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters);
    }    
    process {
        $request = New-CdsRequest -Name "Update";
        $request | Add-CdsRequestParameter -Name "Target" -Value $Record | Out-Null;
        if($BypassCustomPluginExecution)
        {
            $request | Add-CdsRequestParameter -Name "BypassCustomPluginExecution" -Value $true | Out-Null;
        }

        $response = Invoke-CdsRequest -CdsClient $CdsClient -Request $request;
    }
    end {
        $StopWatch.Stop();
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch;
    }    
}

Export-ModuleMember -Function Update-CdsRecord -Alias *;