Teams PowerShell

Had to bulk add a user to multiple Teams and channels today so spent some time with Teams PowerShell.

This cmdlet lists all the teams a user is member of.

The output gives the group ID (GroupId) which is what you need for most other cmdlets. This is the group ID of the O365 group backing the team. You also get the Display Name and other details.

To find the channels in a team:

The output includes the Display Name which can be used for channel related options. Not shown by default, but MembershipType has the channel type.

To find the members of a team:

I wanted to add a user to all (private) channels of a team:

That didn’t work for some reason. Kept throwing a “Could not find member.” error. Not many (or any!) Google hits on that error either.

Tried updating the module but that didn’t help either. Tried using User Id instead of UPN, no luck.

Guess what finally worked! I ran the cmdlet without the -Role switch, it succeeded, and then I re-ran with the -Role Owner switch. I wanted to set the user as Owner so that’s why I had the -Role Owner switch, but that’s optional if you want to add the user as a regular member.

Weird.

To get all the teams and channels of a user:

I had this weird issue today wherein we moved a user across forests and while that preserves the Azure AD account and group memberships and Get-Team even shows the user as belonging to all his teams he wasn’t seeing any of them in Teams itself. I noticed that changing the user from member to owner or owner to member starts showing the team.

I want to do this via PowerShell, but only for Teams that don’t have any private channels (coz I noticed he is removed from them and I wonder if it’s got anything to do with the flipping around; so I want to handle them separately).

To get all teams of a user without private channels (or no channels):

Now to build upon that:

More later…