Skip to content

Instantly share code, notes, and snippets.

@garrytrinder
Created April 9, 2020 08:01
Show Gist options
  • Save garrytrinder/6eeba14bc14d72709d37c45a05c9a647 to your computer and use it in GitHub Desktop.
Save garrytrinder/6eeba14bc14d72709d37c45a05c9a647 to your computer and use it in GitHub Desktop.
Creates a new team from a specified JSON template
$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