Functions/Solutions/Layers/Clear-CdsActiveCustomizations.ps1
<#
.SYNOPSIS Clear active customizations for given solution components #> function Clear-CdsActiveCustomizations { [CmdletBinding()] param ( [Parameter(Mandatory=$false, ValueFromPipeline)] [Microsoft.Xrm.Tooling.Connector.CrmServiceClient] $CdsClient = $Global:CdsClient, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $SolutionUniqueName, [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [int[]] $ComponentTypes = @(26,59,60,61,62,300) ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $components = Get-CdsSolutionComponents -CdsClient $CdsClient -SolutionUniqueName $SolutionUniqueName -ComponentTypes $ComponentTypes; ForEach-ObjectWithProgress -Collection $components -OperationName "Clearing active customizations for $SolutionUniqueName solution" -ScriptBlock { param($component) $componentName = Get-CdsSolutionComponentName -SolutionComponentType $component.componenttype_Value.Value; Remove-CdsActiveCustomizations -CdsClient $CdsClient -SolutionComponentName $componentName -ComponentId $component.objectid; } } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Clear-CdsActiveCustomizations -Alias *; |