Last active
February 19, 2021 22:05
-
-
Save JohnLBevan/0656844cc6d3606dbdac53030fb8c2e1 to your computer and use it in GitHub Desktop.
Gets all users from your directory in Atlassian. Related documentation https://developer.atlassian.com/cloud/admin/user-provisioning/rest/api-group-users/#api-scim-directory-directoryid-users-get.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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