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”
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
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-MgTeam’ cmdlet. 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
Also, you can use the ‘Get-MgTeam’ cmdlet to list the properties related to a specific team by providing TeamsID as a parameter.
Get-MgTeam –TeamId <TeamId>
You can also use advanced tools like AdminDroid to generate instant reports on teams, channels, membership, meetings, membership changes, user activities, Teams usage & adoption, etc.
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
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 chat. You can get the conversation member id of each member in a team by using the ‘Get–MgTeamMember’ cmdlet.
Get-MgTeamMember -TeamId <TeamId> | Select-Object *
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.
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>
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.
To add members or owners to a private channel, you can use the ‘New-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
Note: Members to be added for the Private Channels should be previously a member of that team.
You can use the ‘Remove-MgTeamChannelMember’ cmdlet to remove a user from the private channel.
Remove-MgTeamChannelMember -TeamId <TeamId> -ChannelId <PrivateChannelId> -ConversationMemberId <ConversationMemberId>
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>
To delete a channel in a team, you can delete the group associated with the team. The ‘Remove-MgGroup’ cmdlet must be executed with the group identity for the team deletion process.
Remove-MgGroup -GroupId <GroupId>
To delete a channel in a team, run the ‘Remove-MgTeamChannel ’ cmdlet with team identity and channel identity.
Remove-MgTeamChannel -TeamId <TeamId> -ChannelId <ChannelId>
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
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
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.