Before we all started working from home I liked Microsoft Teams. It had it’s merits over Slack, Discord and Zoom, but I still was not entirely convinced.

Then came COVID-19 and suddenly all communication was through digital means and while this was forced upon us, it meant we had to start using collaboration tooling almost continuously. Microsoft Teams made this transition almost easy. We discovered totally new ways of working together when building software.

Other initiatives like organizing training on the AZ-400 Azure DevOps certification also went virtual and Teams was the solution there as well.

Since some people were still getting used to using Microsoft Teams, sometimes we still had to send every team member an e-mail. Teams has a very handy feature to use a channel e-mail address by right-clicking one of your channels and then click on ‘Get email address’

Getting the e-mail address for you channel

While this is super useful, sometimes you still want to get a list of e-mail addresses for each individual user. Perhaps you want to add user rights to your Active Directory based on their e-mail addresses, or you have some other use-case for which you just want the addresses and not the single e-mail address for the Teams channel.

Enter Powershell. With Powershell, we can just get the list of users for a certain Microsoft Teams team. If you have not installed the Teams Powershell module yet, follow the steps on these Microsoft Docs on installing MS Teams Powershell.

With the Powershell Teams module installed, you can now connect to your Teams environment:

Connect-MicrosoftTeams

You can also include a TenantId or a Powershell credential to be more specific, but a vanilla Connect-command will open a credential window to log in to your Teams environment of choice.

Now that we are logged in, this allows us to issue the ‘Get-TeamUser’-command including the GroupId for the Team selecting the property we need.

Get-TeamUser -GroupId 1234f56c-1234-4c02-ba92-ced12e3c1d45 | Select-Object -Property User

…and it will provide us with a list of e-mail addresses for our Team members.

In case you are wondering where to get the GroupId for your Team, you can just right-click on your Team and copy it over from the ‘Get link to team’-feature.