Public/ScopingCriteria/Get-JIMScopingCriteria.ps1
|
# Copyright (c) Tetron Limited. All rights reserved. # Licensed under the Tetron Commercial License. See LICENSE file in the project root. function Get-JIMScopingCriteria { <# .SYNOPSIS Gets scoping criteria groups for a Synchronisation Rule. .DESCRIPTION Retrieves the scoping criteria groups configured on an export Synchronisation Rule. Scoping criteria define which Metaverse objects are included in the export. Only export Synchronisation Rules support scoping criteria. .PARAMETER SyncRuleId The unique identifier of the Synchronisation Rule. .PARAMETER GroupId Optional. The unique identifier of a specific criteria group to retrieve. .OUTPUTS One or more scoping criteria group objects with their nested criteria. .EXAMPLE Get-JIMScopingCriteria -SyncRuleId 5 Returns all scoping criteria groups for Synchronisation Rule ID 5. .EXAMPLE Get-JIMScopingCriteria -SyncRuleId 5 -GroupId 10 Returns the specific scoping criteria group with ID 10. .LINK New-JIMScopingCriteriaGroup Remove-JIMScopingCriteriaGroup New-JIMScopingCriterion #> [CmdletBinding()] [OutputType([PSCustomObject[]])] param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('Id')] [int]$SyncRuleId, [Parameter()] [int]$GroupId ) process { if (-not $script:JIMConnection) { Write-Error "You are not connected to JIM. Run Connect-JIM -Url <your JIM URL> to authenticate, then try again." return } try { if ($PSBoundParameters.ContainsKey('GroupId')) { Write-Verbose "Getting scoping criteria group $GroupId for Synchronisation Rule $SyncRuleId" $result = Invoke-JIMApi -Endpoint "/api/v1/synchronisation/sync-rules/$SyncRuleId/scoping-criteria/$GroupId" $result | Add-Member -NotePropertyName 'SyncRuleId' -NotePropertyValue $SyncRuleId -PassThru -Force } else { Write-Verbose "Getting all scoping criteria groups for Synchronisation Rule $SyncRuleId" $result = Invoke-JIMApi -Endpoint "/api/v1/synchronisation/sync-rules/$SyncRuleId/scoping-criteria" foreach ($group in $result) { $group | Add-Member -NotePropertyName 'SyncRuleId' -NotePropertyValue $SyncRuleId -PassThru -Force } } } catch { Write-Error "Failed to get scoping criteria: $_" } } } |