Functions/Solutions/Layers/Remove-CdsActiveCustomizations.ps1

<#
    .SYNOPSIS
    Remove active customizations
#>

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

        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [String]
        $SolutionComponentName,

        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Guid]
        $ComponentId
    )
    begin {   
        $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); 
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); 
    }    
    process {

        $removeActiveCustomizationsRequest = New-CdsRequest -Name "RemoveActiveCustomizations";
        $removeActiveCustomizationsRequest = $removeActiveCustomizationsRequest | Add-CdsRequestParameter -Name "SolutionComponentName" -Value $SolutionComponentName;
        $removeActiveCustomizationsRequest = $removeActiveCustomizationsRequest | Add-CdsRequestParameter -Name "ComponentId" -Value $ComponentId;
        $response = $CdsClient | Invoke-CdsRequest -Request $removeActiveCustomizationsRequest;
    }
    end {
        $StopWatch.Stop();
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch;
    }    
}

Export-ModuleMember -Function Remove-CdsActiveCustomizations -Alias *;