Functions/Solutions/Components/Get-CdsSolutionComponents.ps1
<#
.SYNOPSIS Get Solution Components #> function Get-CdsSolutionComponents { [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 = @() ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $solution = $CdsClient | Get-CdsRecord -LogicalName "solution" -AttributeName "uniquename" -Value $SolutionUniqueName; if(-not $solution) { Write-HostAndLog -Message "Solution $SolutionUniqueName not found" -Level FAIL; return $null; } $querySolutionComponents = New-CdsQueryExpression -LogicalName "solutioncomponent" -Columns "objectid", "componenttype"; $querySolutionComponents = $querySolutionComponents | Add-CdsQueryCondition -Field "solutionid" -Condition Equal -Values $solution.Id; if($ComponentTypes.Count -gt 0) { $querySolutionComponents = $querySolutionComponents | Add-CdsQueryCondition -Field "componenttype" -Condition In -Values $ComponentTypes; } $components = $CdsClient | Get-CdsMultipleRecords -Query $querySolutionComponents; $components; } end { $StopWatch.Stop(); Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Get-CdsSolutionComponents -Alias *; |