Skip to content

Instantly share code, notes, and snippets.

@jdmills-edu
Created September 21, 2017 14:10
Show Gist options
  • Save jdmills-edu/dfd9976620455cae009f269ba863727d to your computer and use it in GitHub Desktop.
Save jdmills-edu/dfd9976620455cae009f269ba863727d to your computer and use it in GitHub Desktop.
A PowerShell script that uses the Dropbox Business API to retrieve all users in your tenant. Supports pagination for large tenants.
#API token from https://www.dropbox.com/developers/apps
$token = 'Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
#Create initial DfB team members array:
$teammembers = Invoke-RestMethod -Uri https://api.dropbox.com/2/team/members/list -Body '{}' -ContentType "application/json; charset=utf-8" `
-Headers @{ Authorization = $token } -Method Post
$allDropboxUsers = $teammembers.members.profile
#Keep paginating until we get all the account members.
while($teammembers.has_more -eq "True"){
$json = '{"cursor": "'+$teammembers.cursor+'"}'
$json
$teammembers = Invoke-RestMethod -Uri https://api.dropbox.com/2/team/members/list/continue -Body $json -ContentType "application/json; charset=utf-8" `
-Headers @{ Authorization = $token } -Method Post
$allDropboxUsers += $teammembers.members.profile
}
return $allDropboxUsers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment