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]" = "https://graph.microsoft.com/v1.0/teamsTemplates('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.

By default, every Microsoft 365 user has the ability to create teams via the MS Teams client. If you find yourself frustrated or confused with the multitude of teams they create, you can opt to disable team creations for Microsoft 365 users. This helps make management easier by limiting the creation of teams and groups.

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]" = "https://graph.microsoft.com/v1.0/users(<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 theRemove-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 chat. You 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 

In case if you want to track the recently created channels, you can make use of this dedicated PowerShell script to audit MS Teams channel creations.

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]" = "https://graph.microsoft.com/v1.0/users(<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>

Seamlessly Monitor Microsoft Teams in a Snap with AdminDroid!

Even the Graph PowerShell cmdlets help to retrieve Microsoft Teams details, they are cumbersome and confusing for admins to access in-depth information. However, AdminDroid revolutionizes this process by providing enhanced Teams reports, streamlining Microsoft 365 complex tasks. A user-friendly interface and overall visibility of AdminDroid’s reports contribute to risk reduction, increased efficiency, and improved compliance.

AdminDroid’s Microsoft Teams reporting tool is a powerful solution that allows you to monitor all the Teams and their properties efficiently in a single console. With the following reports collection, you can gain a deeper understanding of your Teams usage and take actions to enhance productivity and communication within your organization:

  • Microsoft Teams Overview Statistics
  • Teams Membership Reports
  • Standard Channels Reports
  • MS Teams Private Channels Reports
  • Microsoft Teams Usage Statistics
  • Teams Apps and Tabs Reports
  • Settings and Permissions in MS Teams

Microsoft Teams Overview Report - AdminDroid

Furthermore, AdminDroid’s Teams audit reports offers real-time monitoring of Microsoft Teams events, including setting changes, membership modifications, external sharing activities, etc. Stay on top of your Teams environment’s security and ensure smooth collaboration with the extensive auditing reports collection from AdminDroid.

  • Teams Login Activities and Setting Changes
  • Microsoft Teams Management Audit
  • MS Teams File Access and External Sharing Audit
  • Teams Add-on and App Management Audit
  • Membership Changes in Teams
  • Data Loss Prevention Actions

MS Teams Channel Activities - AdminDroid

Moreover, the Teams dashboard gallery gives a bird’s eye view of the entire Teams and its usage. Overall, the AdminDroid Teams management tool covers 110+ inclusive reports that give clear-cut details that reduce the risk of sensitive files landing in the wrong hands.

Looking for reasons to choose AdminDroid? We have the perfect answer for you.

In addition to Teams Reporting, AdminDroid offers a wealth of 1800+ pre-built reports on Microsoft 365 services, including Azure AD, Exchange Online, SharePoint Online, etc. The AdminDroid reporting tool also excels in features such as alerting, granular delegation, compliance, usage and adoption of Microsoft 365 reports.

Take a look at the AdminDroid demo and download it today to monitor your Microsoft 365 environment!

Thus, I hope this blog will help every Office 365 admin to manage the Microsoft Teams environment efficiently. 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: 5 min
0