Hello everyone, this is the first of many articles I hope to post about managing Microsoft 365 using PowerShell. In this first article, I want to show you how to perform basic administration tasks in Microsoft Teams using PowerShell. Important:
- You must use your Teams administrator account to perform these steps.
PowerShell Workaround #
First, you need to make sure the MicrosoftTeams module is installed on your computer and then imported into your Powershell session. To do that, you should use the following commands.
Install-Module -Name MicrosoftTeams Import-Module -Name MicrosoftTeams
Once you have imported the module, you are ready to start.
Connect to Microsoft Teams #
The easiest way to get started is to log in interactively at the command line.
Creates a new Team #
The New-Team cmdlet creates a new team to use in Microsoft Teams and will provide a unified O365 group to support the team.
New-Team ` -DisplayName "My Demo Team" ` -Description "Internal Collaboration place for the Demo Team" ` -Visibility Private
You can create teams as public, private, or org-wide. For public teams, Anyone using Teams in your organization can join. For private teams, team owners manage team membership. And for an org-wide team, all members of your organization are automatically added.
Get existing Teams #
To retrieve all teams in the organization, you should use the Get-Team cmdlet. You can use the following parameters to retrieve teams with particular properties.
Get-Team ` -GroupId <String> ` -User <String> ` -Archived <Boolean> ` -Visibility <String> ` -DisplayName <String> ` -MailNickName <String>
Update Team Properties #
If you want to update the properties of a team, you should use the Set-Team cmdlet with the following syntax.
$team = Get-Team ` -DisplayName "My Demo Team" Set-Team ` -GroupId $team.GroupId ` -AllowChannelMentions $false ` -AllowCreateUpdateChannels $false ` -AllowUserDeleteMessages $false ` -AllowUserEditMessages $false ` -AllowAddRemoveApps $false ` -AllowGiphy $false ` -AllowStickersAndMemes $false
Create a new channel for a Team #
Once the Team is deployed, you can create a channel for that team; To do this, you should use the New-TeamChannel cmdlet with the following syntax.
New-TeamChannel ` -DisplayName "MyChannel” ` -GroupId $team.GroupId ` -MembershipType Private
Update Team channel settings #
If you want to update the properties of a channel, you should use the Set-TeamChannel cmdlet with the following syntax.
Set-TeamChannel ` -GroupId $team.GroupId ` -CurrentDisplayName "MyChannel" ` -NewDisplayName "MyNewChannel" ` -Description "Use this channel to share project material."
To obtain information about a team channel, you should use the Get-TeamChannel cmdlet.
Get-TeamChannel ` -GroupId $team.GroupId
Delete a Team channel #
Deleting a channel in teams using PowerShell should be done using the Remove-TeamChannel cmdlet with the following syntax.
Remove-TeamChannel ` -GroupId $team.GroupId ` -DisplayName "MyNewChannel”
Get the members of a Team #
You can use the Get-TeamUser cmdlet to get the list of team members. Using the -role parameter, you can filter the owners\members of the team.
Get-TeamUser ` -GroupId $team.GroupId ` -Role Owner Get-TeamUser ` -GroupId $team.GroupId ` -Role Member
Add members to the Team #
You can add members or owners to the team using the Add-TeamUser cmdlet with the following syntax.
Add-TeamUser ` -GroupId $team.GroupId ` -User User01@jorgebernhardt.com Add-TeamUser ` -GroupId $team.GroupId ` -User Owner01@jorgebernhardt.com ` -Role Owner
Remove members from a Team #
If you’re a team owner, you can remove someone from your team. To do this, you should use the Remove-TeamUser cmdlet with the following syntax.
Remove-TeamUser ` -GroupId $team.GroupId ` -User User01@jorgebernhardt.com
Deletes a Team from Microsoft Team #
Finally, if you want to remove the team, you should use the cmdlet with the following syntax.
Remove-Team ` -GroupId $team.GroupId
Thanks for reading my post. I hope you find it helpful.
If you want to learn more about the Microsoft Teams PowerShell module, check out this link.