Top 10 cmdlets to Manage Teams using Microsoft Graph PowerShell

Top 10 cmdlets to Manage Teams using Microsoft Graph PowerShell

Managing Microsoft Teams can be a daunting and time-consuming task, especially in the context of larger organizations that have numerous teams and channels to oversee. Microsoft 365 admins can manage teams using PowerShell, Teams admin center, or Microsoft Graph PowerShell. Here, we provide you with top 10 cmdlets that can be used to manage Teams using Microsoft Graph PowerShell efficiently. 

Microsoft Graph is a unified programmability model that lets you work with Microsoft 365 data. It comprises multiple PowerShell modules that directly map to Microsoft Graph API commands. Before getting started to manage teams via Graph PowerShell, admins must install and connect to Microsoft Graph PowerShell with the global administrator.  

Note: You must use the following as the scopes while connecting to Microsoft Graph to manage Microsoft Teams. 

  • “Group.ReadWrite.All” 
  • “GroupMember.ReadWrite.All” 
  • “TeamSettings.ReadWrite.All” 
  • “TeamsTab.ReadWrite.All” 
  • “TeamMember.ReadWrite.All” 
  • “ChannelMember.ReadWrite.All” 


Create and Manage Teams Using Graph PowerShell 

You can create a new team using the New-MgTeam cmdlet. For example,    

$params = @{ 
"[email protected]" = "'standard')" 
DisplayName = <TeamName> 
Description = <Description> 
New-MgTeam -BodyParameter $params 

Create New Teams Using PowerShell

When you create a team, it automatically creates Office 365 unified group, SharePoint site, and Planner in the backend.    

You can update the existing properties related to the team using the ‘Update-MgTeamcmdlet. Give the required parameters in the cmdlet to update the properties for the desired team. 

$params = @{ 
MemberSettings = @{ 
AllowCreateUpdateChannels = <TrueOrFalse> 
MessagingSettings = @{ 
AllowUserEditMessages = <TrueOrFalse> 
AllowUserDeleteMessages = <TrueOrFalse> 
FunSettings = @{ 
AllowGiphy = <TrueOrFalse> 
GiphyContentRating = <ModerateOrStrict> 
Update-MgTeam -TeamId <TeamId> -BodyParameter $params

Update team Properties

Also, you can use theGet-MgTeamcmdlet to list the properties related to a specific team by providing TeamsID as a parameter. 

Get-MgTeamTeamId <TeamId> 

Get Properties of Team Using Graph PowerShell


Add Member to Team 

To add users to a specific team, use the New-MgTeamMember cmdlet as shown below. 

$params = @{ 
"@odata.type" = "#microsoft.graph.aadUserConversationMember" 
roles = @(<MemberOrOwner>) 
"[email protected]" = "<UPN>)" 
New-MgTeamMember -TeamId <TeamId> -BodyParameter $params 

Add Member to Team Using Graph PowerShell


Remove Users from Microsoft Teams

To remove an owner or member from a team, you can use the ‘Remove-MgTeamMember cmdlet.

Remove-MgTeamMember  -TeamId <TeamId> -ConversationMemberId <ConversationMemberId> 

Where, conversation member Id is a unique identity used to represent a user in a team, a channel, or a chatYou can get the conversation member id of each member in a team by using the ‘GetMgTeamMembercmdlet.  

Get-MgTeamMember -TeamId <TeamId> | Select-Object * 

Remove Users from Microsoft Teams

Note: When you want to remove the last owner from a team, first assign another owner and change their existing owner role to member, then remove them. 


Create a Channel in Teams 

After creating a team, you can create channels under that team using the New-MgTeamChannel cmdlet using the following syntax.  

New-MgTeamChannel -TeamId <TeamId> -DisplayName <Channel Name> -Description <Description> 

Create Channel in Teams

The above format creates a standard channel. To create a private channel, run the above code with the ‘MembershipType’ parameter. Private channels are not visible to all team members by default, and only team members who are added as members of the private channel can access its content.

For example, 

New-MgTeamChannel -TeamId 126b90a5-e65a-4fef-98e3-d9b49f4acf12 -DisplayName "Confidential" -MembershipType Private 


Add Members to Teams Private Channel Using Graph PowerShell 

To add members or owners to a private channel, you can use theNew-MgTeamChannelMember cmdlet. To add a user as a member, run the following code.    

$params = @{
"@odata.type" = "#microsoft.graph.aadUserConversationMember"
Roles = @(<OwnerOrMember>)
"[email protected]" = "<UPN>)"
New-MgTeamChannelMember -TeamId <TeamId> -ChannelId <ChannelId> -BodyParameter $params

Add Members to Teams Private Channel Using Graph PowerShell
Note: Members to be added for the Private Channels should be previously a member of that team. 


Remove Members from Private Channel   

You can use the Remove-MgTeamChannelMember’ cmdlet to remove a user from the private channel. 

Remove-MgTeamChannelMember -TeamId <TeamId> -ChannelId <PrivateChannelId> -ConversationMemberId  <ConversationMemberId>

emove Members from Private Channel


Archive Microsoft Teams 

When a team is no longer active but wants to keep the content accessible, you can archive it using the Invoke-MgArchiveTeam cmdlet. Also, you can reactivate the archived teams if needed.   

To archive a specific team,   

Invoke-MgArchiveTeam -TeamId <TeamId> 

To unarchive a team, run the ‘Invoke-MgUnarchiveTeam cmdlet with the team Id.

Invoke-MgUnarchiveTeam -TeamId <TeamId> 


Delete Teams Using Microsoft Graph PowerShell 

To delete a channel in a team, you can delete the group associated with the team. The ‘Remove-MgGroupcmdlet must be executed with the group identity for the team deletion process. 

Remove-MgGroup -GroupId <GroupId>


Delete Channels Using Microsoft Graph PowerShell  

To delete a channel in a team, run the ‘Remove-MgTeamChannel cmdlet with team identity and channel identity. 

Remove-MgTeamChannel -TeamId <TeamId> -ChannelId <ChannelId> 


Thus, I hope this blog will help every Office 365 admin to manage the Microsoft Teams Environment using Microsoft Graph PowerShell. Feel free to reach us in the comments for any assistance.     

Top 10 cmdlets to Manage Teams using Microsoft Graph PowerShell

by Thiraviam time to read: 3 min