Skip to content

Instantly share code, notes, and snippets.

@JohnLBevan
Last active February 19, 2021 22:05
Show Gist options
  • Save JohnLBevan/0656844cc6d3606dbdac53030fb8c2e1 to your computer and use it in GitHub Desktop.
Save JohnLBevan/0656844cc6d3606dbdac53030fb8c2e1 to your computer and use it in GitHub Desktop.
function Get-AtlassianScimUsers {
[CmdletBinding()]
Param (
[Parameter(Mandatory)]
[string]$DirectoryId
,
[Parameter(Mandatory)]
[string]$Token
)
$startIndex = 1
$totalResults = 2
while ($startIndex -lt $totalResults) {
$results = Invoke-RestMethod -Method GET -Uri "https://api.atlassian.com/scim/directory/$($DirectoryId)/Users?startIndex=$($startIndex)" -Headers @{Authorization = "Bearer $Token"; Accept = 'application/json'; 'Content-Type' = 'application/json';} -ErrorAction Stop
$results.Resources
$totalResults = $results.totalResults
$startIndex += $results.itemsPerPage
}
}
[PSObject[]]$all = Get-AtlassianScimUsers -DirectoryId $myDirectoryId -Token $myToken
$all | Measure-Object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment