Created
April 9, 2020 08:01
-
-
Save garrytrinder/6eeba14bc14d72709d37c45a05c9a647 to your computer and use it in GitHub Desktop.
Creates a new team from a specified JSON template
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
$token = o365 util accesstoken get -r "https://graph.microsoft.com" --new | |
$template = Get-Content -Path ./template.json | |
$options = @{ | |
Method = "Post" | |
Uri = "https://graph.microsoft.com/beta/teams" | |
ContentType = "application/json" | |
Body = $template | |
Headers = @{ | |
"Authorization" = "Bearer $token"; | |
"Accept" = "application/json" | |
} | |
} | |
try { | |
$response = Invoke-WebRequest @options | |
$response.Headers.Location | |
Write-Host "Team succesfully created" -ForegroundColor Green | |
} | |
catch { | |
Write-Host "There was an error creating the team" | |
Write-Host $_.Exception | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment