Created
September 21, 2017 13:58
-
-
Save jdmills-edu/71bfbe8a68fc5a91bf0b353904e6a906 to your computer and use it in GitHub Desktop.
A PowerShell script that checks a given OU for security groups, creating a new Team Folder if it finds a security group without a matching Team Folder. Useful for automatically creating Team Folders for every departmental security group in a given OU. Run this as a scheduled task.
This file contains 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
$dfbToken = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
$ou = "OU=YourOU,DC=domain,DC=com" | |
$groups = Get-ADGroup -SearchBase $ou -Filter * | Sort Name | |
#List Team Folders | |
$headers = @{ | |
Authorization = "Bearer $dfbToken" | |
} | |
$teamFolders = Invoke-RestMethod -Method Post -Uri https://api.dropboxapi.com/2/team/team_folder/list -Headers $headers -ContentType application/json -Body "{}" | |
$teamFolders = $teamFolders.team_folders.Name | |
$newTeamFolders = @() | |
$groups | ForEach-Object { | |
$thisDeptName = $_.Name | |
if($teamFolders.Contains($thisDeptName)){ | |
Write-Host "$thisDeptName already has a Team Folder." -ForegroundColor Green | |
} | |
else{ | |
$requestBody = '{"name":"'+$thisDeptName+'"}' | |
Write-Host "$thisDeptName needs a new Team Folder! Creating..." -ForegroundColor Cyan | |
$newTeamFolders += Invoke-RestMethod -Method Post -Uri https://api.dropboxapi.com/2/team/team_folder/create -Headers $headers -ContentType application/json -Body $requestBody | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script doesn't handle automatic permissions assignment to the departmental group's Team Folder... yet.