Created
September 21, 2017 14:10
-
-
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.
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
#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