PowerShell ยป Manage teams

PowerShell scripts for Microsoft 365

How to manage Microsoft Teams using PowerShell

The New-Team cmdlet helps create a new team and its associated unified Microsoft 365 group. You can also specify team settings using the following script.

  1.  New-Team
  2.   [-DisplayName <String>]
  3.   [-Description <String>]
  4.   [-MailNickName <String>]
  5.   [-Classification<String>]
  6.   [-Visibility <String>]
  7.   [-Template <String>]
  8.   [-Owner <String>]
  9.   [-AllowGiphy <Boolean>]
  10.   [-GiphyContentRating <String>]
  11.   [-AllowStickersAndMemes <Boolean>]
  12.   [-AllowCustomMemes <Boolean>]
  13.   [-AllowGuestCreateUpdateChannels <Boolean>]
  14.   [-AllowGuestDeleteChannels <Boolean>]
  15.   [-AllowCreateUpdateChannels <Boolean>]
  16.   [-AllowDeleteChannels <Boolean>]
  17.   [-AllowAddRemoveApps<Boolean>]
  18.   [-AllowCreateUpdateRemoveTabs<Boolean>]
  19.   [-AllowCreateUpdateRemoveConnectors<Boolean>]
  20.   [-AllowUserEditMessages<Boolean>]
  21.   [-AllowUserDeleteMessages<Boolean>]
  22.   [-AllowOwnerDeleteMessages<Boolean>]
  23.   [-AllowTeamMentions<Boolean>]
  24.   [-AllowChannelMentions<Boolean>]
  25.   [-ShowInTeamsSearchAndSuggestions<Boolean>]
  26.   [-RetainCreatedGroup<SwitchParameter>]
  27.   [<CommonParameters>]

The following script helps create a team from an existing Microsoft 365 group. The script shows only a few team settings for example purposes.

  1.  New-Team
  2.   -GroupId <String>]
  3.   [-Owner <String>]
  4.   [-AllowGiphy <Boolean>]
  5.   [-GiphyContentRating<String>]
  6.   [-AllowStickersAndMemes <Boolean>]
  7.   [-AllowCustomMemes <Boolean>]
  8.   [-AllowGuestCreateUpdateChannels <Boolean>]
  9.   [-AllowGuestDeleteChannels <Boolean>]
  10.   [-RetainCreatedGroup <SwitchParameter>]
  11.   [<CommonParameters>]

Example 1: You can also create channels and add users to the newly created team.

  1. Connect-MicrosoftTeams -AccountId lucy@test.com
  2. $group = New-Team -MailNickname "TestTeam" -displayname "Work force" -Visibility "private"
  3. Add-TeamUser -GroupId $group.GroupId -User "Akash@test.com"
  4. Add-TeamUser -GroupId $group.GroupId -User "Mia@test.com"
  5. New-TeamChannel -GroupId $group.GroupId -DisplayName "marketing"
  6. New-TeamChannel -GroupId $group.GroupId -DisplayName "Sales"

Cmdlet: Set-Team

This cmdlet helps update team properties such as display name, description, visibility and the team settings. (Refer New-Team cmdlet script for team settings).

Example: Updating a team's DisplayName.

1 Set-Team -GroupId 2f162b0e-36d2-4e15-8ba3-ba229cecdccf -DisplayName "Updated TeamName" -Visibility Public

Cmdlet: Remove-Team

This cmdlet deletes the specified team and the group associated with it.

  1.   Remove-Team
  2.   -GroupId<String>
  3.   [<CommonParameters>]

Using PowerShell to manage Microsoft Teams requires you to have appropriate permissions. It can also be complex, time-consuming and error-prone. M365 Manager Plus helps simplify Teams management with its bulk management feature.

How can M365 Manager Plus help?

The user-friendly interface helps you easily create, update, and delete teams in bulk by simply importing a CSV file. You can also create automated workflows in the tool to manage Teams. This will help save time and reduce your workload.

Managing Microsoft teams in bulk using M365 Manager Plus:

  1. Navigate to the Management tab.
  2. Go to Microsoft Teams in the left pane.
  3. Select Team Tasks > Create Team or any other required action.
  4. Select the required Microsoft 365 Tenant from the drop-down box.
  5. Import the required CSV file.
  6. Click Import Team(s).
Create Team From Group

The imported CSV file must consist of details such as DisplayName, Description, Visibility, Owner, and rules that help manage user permissions in Microsoft Teams.

To learn more about managing Microsoft Teams using M365 Manager Plus, click here.