Microsoft Teams : Get all your teams data using Powershell

Now we can get the list of teams where the current user is being a member using Microsoft Teams Powershell. Before proceed first you have to install Microsoft Teams Powershell using below command.

Install-Module MicrosoftTeams -Force

Note: You have to run the powershell with “Run as administrator” privilege to install this module.

Once you have installed the Teams module, then run the following command to connect Microsoft Teams and it will ask your credentials to proceed.

Connect-MicrosoftTeams

List all your Teams:

Once you have completed the login step, run the Get-Team command to list all your teams.

PS C:> Get-Team

GroupId                              DisplayName        Description
-------                              -----------        -----------
9b614bd6-6710-44ae-a9e7-3446334546d7 Team 1             Team 1 Description
7d6143d6-2612-44ae-a9e7-2473364843f5 Team 2             Team 2 Description

List all channels in a Team:

You can get channels of a specific team by running following command. You can get the <Group Id> of the specific team from Get-Team command.

Get-TeamChannel -GroupId <Group Id>

Get Team members and their role:

You can also get members of a specific team and their role (owner or member) by running following command.

Get-TeamUser -GroupId <Group Id>

Note : Using Get-Team cmdlet you can get only your own teams, you can’t get teams list of specific user even if you have administrator privilege. The Get-Team cmdlet actually included the parameter -User to get other user teams information, but as of now you will get only access denied (‘Get-Team : Error occurred while executing Code: AccessDenied‘) error message even for global administrator.

PS C:Windowssystem32> Get-Team -User [email protected]
Get-Team : Error occurred while executing
Code: AccessDenied
Message: Invalid UserId. UserId does not match Access token UserObjectId
InnerError: RequestId: f8664d28-5514-4bef-907e-f7a880907bc7 DateTimeStamp: 2018-05-11T16:59:53
HttpStatusCode: AccessDenied
At line:1 char:1
+ Get-Team -User [email protected]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-Team], ApiException
    + FullyQualifiedErrorId : Microsoft.TeamsCmdlets.PowerShell.Custom.ErrorHandling.ApiException,Microsoft.TeamsCmdle
   ts.PowerShell.Custom.GetTeam

Advertisement

Leave a Comment