Functions/Client/Remove-CdsRecord.ps1
<#
.SYNOPSIS Remove entity record in CRM. #> function Remove-CdsRecord { [CmdletBinding()] param ( [Parameter(Mandatory = $false, ValueFromPipeline)] [Microsoft.Xrm.Tooling.Connector.CrmServiceClient] $CdsClient = $Global:CdsClient, [Parameter(Mandatory = $true, ValueFromPipeline)] [Microsoft.Xrm.Sdk.Entity] $Record ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { Protect-CdsCommand -ScriptBlock { $CdsClient.Delete($Record.LogicalName, $Record.Id) }; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Remove-CdsRecord -Alias *; |