Public/Get-IAMCoreSyncCoreObject.ps1
|
function Get-IAMCoreSyncCoreObject { [CmdletBinding(DefaultParameterSetName = "Default")] param ( [Parameter(Mandatory = $true)] [ValidateSet("CoreIdentity", "CoreOrgUnit", "CoreRelationship")] [String] $ObjectType, [Parameter(Mandatory = $false)] [int] $PageSize = 10000 ) if (-not $Script:APIRoot -or -not $Script:AccessTokenProfile) { throw "Not connected to IAM Core. Please run Connect-IAMCore first." } $Uri = "$Script:APIRoot/sync/coreobjects/" switch ($ObjectType) { "CoreIdentity" { $Uri += "identities" } "CoreOrgUnit" { $Uri += "orgunits" } "CoreRelationship" { $Uri += "relationships" } } $CurrentUri = "$($Uri)?pageSize=$($PageSize)" while ($CurrentUri) { $Result = Invoke-RestMethod -Uri $CurrentUri -Headers (Get-IAMCoreHeader) $CurrentUri = $null if ($Result.IsSuccess) { $Result.Data if($Result.NextCursor) { Write-Debug "Next cursor: $($Result.NextCursor)" $CurrentUri = "$($Uri)?pageSize=$($PageSize)&nextCursor=$($Result.NextCursor)" } } else { throw "Failed to get IAM Core object: $($Result.ErrorMessage)" } } } |