Creating and managing Teams efficiently is a key responsibility for Microsoft 365 administrators. While the Teams Admin Center provides a graphical interface, the New-MgTeam cmdlet offers a powerful way to automate Team creation tasks and integrate them into larger workflows.
What Is Microsoft Teams?
Microsoft Teams is a collaboration platform within Microsoft 365 that integrates chat, video conferencing, file sharing, and productivity tools. Each Team connects users with shared resources like:
- A shared mailbox and calendar in Outlook.
- A SharePoint document library for file management.
- Planner for task tracking.
- OneNote for collaborative note-taking.
Teams can be created for various purposes, including department communication, project management, and cross-functional collaboration.
Why Use New-MgTeam?
The New-MgTeam cmdlet simplifies the process of creating Microsoft Teams programmatically. Key benefits include:
- Automation: Create multiple Teams or replicate existing structures without manual effort.
- Consistency: Ensure Teams follow standardized naming conventions, descriptions, and settings.
- Scalability: Handle large-scale Team creation tasks efficiently.
By using New-MgTeam, administrators can save time, reduce errors, and maintain consistency across their Microsoft 365 environment.
Setting Up Microsoft Graph PowerShell
Before using the New-MgTeam cmdlet, you’ll need to install and configure the Microsoft Graph PowerShell module:
- Install Microsoft Graph PowerShell: Install the module with this command:
Install-Module Microsoft.Graph -Scope CurrentUser - Connect to Microsoft Graph: Establish a connection to your Microsoft 365 tenant with the required permissions:
You’ll be prompted to authenticate with your admin credentials.Connect-MgGraph -Scopes "Group.ReadWrite.All" - Disconnect After Use: Once you’ve completed your tasks, disconnect the session to ensure security:
Disconnect-MgGraph
Practical Examples of New-MgTeam
Let’s dive into some practical use cases for New-MgTeam to demonstrate its flexibility and power.
Create a Single Team
To create a single Microsoft Team with basic settings:
$team = @{
DisplayName = "Team Name"
Description = "This is a sample team"
Visibility = "Public"
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
}
New-MgTeam -BodyParameter $team
This creates a public Team named "Team Name" using the standard Teams template.
Create Multiple Teams from a CSV File
For bulk Team creation, you can import details from a CSV file.
CSV File Example:
DisplayName,Description,Visibility
"Finance Team","Team for finance department","Private"
"HR Team","Team for HR department","Public"
$teams = Import-Csv -Path "C:\path\to\teams.csv"
foreach ($team in $teams) {
$teamParams = @{
DisplayName = $team.DisplayName
Description = $team.Description
Visibility = $team.Visibility
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
}
New-MgTeam -BodyParameter $teamParams
}
This script creates a Team for each row in the CSV file, ensuring consistency and scalability.
Create a Team from an Existing Group
If you already have an Office 365 group and want to convert it into a Team:
$params = @{
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"
"group@odata.bind" = "https://graph.microsoft.com/v1.0/groups('your-group-id')"
}
New-MgTeam -BodyParameter $params
Advanced Tips for New-MgTeam Usage
- Customize Team Templates: You can use different templates for Teams creation, such as Education or Retail. Update the template@odata.bind value to match the required template:
https://graph.microsoft.com/v1.0/teamsTemplates('educationClass') - Automate End-to-End Workflows: Combine New-MgTeam with other cmdlets like Add-MgTeamMember to automate complete Team setups, including adding members and setting permissions.
- Simulate Commands Before Execution: Use the -WhatIf parameter to preview the results of a command without making changes:
New-MgTeam -BodyParameter $team -WhatIf
Conclusion
The New-MgTeam cmdlet is a versatile tool that empowers Microsoft 365 administrators to create Teams programmatically. Whether you’re handling a single Team, performing bulk creation, or converting existing groups, this cmdlet simplifies workflows and ensures consistency.
By mastering New-MgTeam and following best practices, you can streamline your organization’s Teams management and boost productivity.
Start scripting with New-MgTeam today and take control of your Microsoft 365 Teams environment!
🚀 Community Edition Released!
Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams
Get it on GitHub Know More