Share via

How to Create MS TEAMS for all Existing Office 365 Groups via PowerShell in One go.

Anonymous
2019-04-21T03:30:41+00:00

Hello Everyone.

Greetings!!!!

I would like to share some insights on How to Create MS TEAMS for all Existing Office 365 Groups via PowerShell.

As we know that creating Teams from Office 365 Groups is very easy task but if we have to create multiple Teams using GUI is very complex and Time consuming.

So I made a script in which we can Create MS TEAMS for all Existing Office 365 Groups in One Go.

Please perform the following action plan to achieve this.

(Note: If the Team is already created for the same Office 365 Group then we will get an error or warning for the same.)

Step 1: Connect to Exchange PowerShell.

Run the following commands to Connect with Exchange PowerShell:

  1. Set-ExecutionPolicy Unrestricted
  2. $UserCredential = Get-Credential
  3. $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  4. Import-PSSession $Session

Step 2: Connect to MS TEAMS PowerShell:

  1. Install-Module -Name MicrosoftTeams
  2. Connect-MicrosoftTeams

Step 3: Run the Following command to ignore the Error messages or Warnings from the PS session.

  1. $ErrorActionPreference = 'SilentlyContinue'

Now, Run the following commands to Create Teams for all Existing Office 365 Groups.

• Get-UnifiedGroup | % {New-Team -group $_.ExternalDirectoryObjectId}

You will get the output for the Groups with GroupIDs (e.g. 11ed4b69-66b9-4571-8ccc-82fc3d######) for which MS TEAMS has been created.

You can check Group Details using the GroupID by running the following command:

• Get-UnifiedGroup 11ed4b69-66b9-4571-8ccc-82fc3d######

In order to cross verify, you can navigate to MS TEAMS client/Web client and check that Teams there, If you are the part of that Office 365 Group.

If you want to create a Team for Particular Group then please refer the action plan mentioned below:

  • (Get-UnifiedGroup).ExternalDirectoryObjectId

You will get GroupId's for all Office 365 group and then you can Run the Following command to Create a Team for that Group:

For e.g.

New-Team -Group f1acde4f-6d3b-42f8-b738-29556c######

( Note: If the Team is already created for the same Office 365 Group then we will get an error or warning for the same.)

I am trying to compile a script which will differentiate between the Groups for which Team has been created and the Groups for which it is not.

Please let me know if you have any queries on this. 

Please ignore if you already aware about it.

Regards,

Shrikant Suravase

Microsoft Teams | Microsoft Teams for business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2019-08-09T02:22:20+00:00

    My 2 cents, your post help me ;)

    ######################################################################

    Please install the next modules :

    Install-Module MicrosoftTeams -Force -Verbose

    ExOnline module from ECP

    ######################################################################

    To Execute:

    PS C:> Connect-EXOPSSession -UserPrincipalName *** Email address is removed for privacy ***

    PS C:> Connect-MicrosoftTeams

    ######################################################################

    $GroupsAvailable = $null

    $Groups4Teams = $null

    $Group4Teams = $null

    $GroupID = $null

    Select all the groups available for Teams

    $GroupsAvailable = Get-UnifiedGroup | select DisplayName,ExternalDirectoryObjectId

    Select specific groups to Teams by DisplayName

    $Groups4Teams = $GroupsAvailable | Where {$_.DisplayName -like "TST-*"}

     foreach ($Group4Teams in $Groups4Teams) {

      echo $Group4Teams.DisplayName #Check

      

      # DisplayName for Teams, by default take the name of the group

      $TeamName = "MRE - " + $Group4Teams.DisplayName

      

      #Group ID to var

      $GroupID = $Group4Teams.ExternalDirectoryObjectId

      

      #New Team command to create

      New-Team -Group $GroupID

      

      #Set Team DisplayName

      Set-Team -Group $GroupID -DisplayName $TeamName

      }

    @ProfKaz, Thank you for sharing additional information on this. I really appreciate your efforts.

    -Shrikant Suravase

    Was this answer helpful?

    6 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2019-04-22T01:33:27+00:00

    Hello Shrikant,

    Thanks for your kindly sharing in the forum. Other community members who have the same problems on creating Teams via PowerShell will benefit from your sharing. Meanwhile, if you have any problems when using Office 365, please feel free to post a new thread in the forum. Our agents are pleased to help you. 

    Regards,

    Rick

    Was this answer helpful?

    5 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2019-05-24T20:11:38+00:00

    My 2 cents, your post help me ;)

    ######################################################################

    Please install the next modules :

    Install-Module MicrosoftTeams -Force -Verbose

    ExOnline module from ECP

    ######################################################################

    To Execute:

    PS C:> Connect-EXOPSSession -UserPrincipalName ******@tenantName.onmicrosoft.com

    PS C:> Connect-MicrosoftTeams

    ######################################################################

    $GroupsAvailable = $null

    $Groups4Teams = $null

    $Group4Teams = $null

    $GroupID = $null

    Select all the groups available for Teams

    $GroupsAvailable = Get-UnifiedGroup | select DisplayName,ExternalDirectoryObjectId

    Select specific groups to Teams by DisplayName

    $Groups4Teams = $GroupsAvailable | Where {$_.DisplayName -like "TST-*"}

     foreach ($Group4Teams in $Groups4Teams) {

      echo $Group4Teams.DisplayName #Check

      # DisplayName for Teams, by default take the name of the group

      $TeamName = "MRE - " + $Group4Teams.DisplayName

      #Group ID to var

      $GroupID = $Group4Teams.ExternalDirectoryObjectId

      #New Team command to create

      New-Team -Group $GroupID

      #Set Team DisplayName

      Set-Team -Group $GroupID -DisplayName $TeamName

      }

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments