src/Metadata/Remove-XrmRelationship.ps1
|
<# .SYNOPSIS Delete a relationship from Microsoft Dataverse. .DESCRIPTION Delete a relationship using DeleteRelationshipRequest. .PARAMETER XrmClient Xrm connector initialized to target instance. Use latest one by default. (Dataverse ServiceClient) .PARAMETER Name Relationship schema name to delete. .OUTPUTS Microsoft.Xrm.Sdk.OrganizationResponse. The DeleteRelationship response. .EXAMPLE Remove-XrmRelationship -Name "new_account_contact"; #> function Remove-XrmRelationship { [CmdletBinding()] [OutputType([Microsoft.Xrm.Sdk.OrganizationResponse])] param ( [Parameter(Mandatory = $false, ValueFromPipeline)] [Microsoft.PowerPlatform.Dataverse.Client.ServiceClient] $XrmClient = $Global:XrmClient, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $Name ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-XrmFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $request = [Microsoft.Xrm.Sdk.Messages.DeleteRelationshipRequest]::new(); $request.Name = $Name; $response = Invoke-XrmRequest -XrmClient $XrmClient -Request $request; $response; } end { $StopWatch.Stop(); Trace-XrmFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Remove-XrmRelationship -Alias *; |