How I create Microsoft Teams in PowerShell, January 2018

This is how I choose to create Microsoft Teams using PowerShell in the period of January 2018 as demoed in my NICconf session. This will probably change in the future so I need to specify the time this actually worked for me :)

  • I create the Office 365 Group in Exchange because then I can specify the email address and I also like to remove it from global addressbook since it is primarily used for Microsoft Teams
  • Then I Teams enable the group and typically it is created for projects so I create typical channels I want to use in the project, typically it is an Office 365 migration and deployment projects
  • Typically I leave it up to the group owners to add the members themselves in Microsoft Teams, but I use Teams PowerShell to add the owners and optionally members, because it is simpler to do it using Teams
  • The Microsoft Teams PowerShell module is based on Microsoft Graph and everything is in the context of your admin account, so in order to administer the Teams, you need to be an owner of those Teams
  • Be aware of that it can take up to 24 hours until members and channels are added to the Microsoft Teams because this is Microsoft Graph and the SLA is 24 hours to sync members over from Azure AD. Typically this should happen within 15 minutes
    • This is how it is as of January 2018
#Create the Office 365 Group
New-UnifiedGroup –DisplayName NICDemo96 –Alias NICDemo96 –EmailAddresses "NICDemo96@M365x963508.onmicrosoft.com" -owner GA-sha256@M365x963508.onmicrosoft.com -RequireSenderAuthenticationEnabled $False -Verbose
#This is optional, but may be a good practice initially since Office 365 Groups may clutter your Global Addressbook
Set-UnifiedGroup –Identity NICDemo96 –HiddenFromAddressListsEnabled $true
#Create the Team, provide the GUID object ID to specify the Group
$group = New-Team -Group (Get-UnifiedGroup NICDemo96).ExternalDirectoryObjectId -Verbose

#Check your Teams, will only list teams you are a member of
Get-Team

#Add Channels to the Team
New-TeamChannel -GroupId $group.GroupId -DisplayName "1 Adoption" -Verbose
New-TeamChannel -GroupId $group.GroupId -DisplayName "2 Deployment" -Verbose
New-TeamChannel -GroupId $group.GroupId -DisplayName "3 Operations" -Verbose
New-TeamChannel -GroupId $group.GroupId -DisplayName "4 Change Management" -Verbose
Set-TeamFunSettings -GroupId $group.GroupId -AllowCustomMemes true -Verbose

#add owners and members, easier to do with Teams cmdlet
$Owners = "PradeepG@M365x963508.onmicrosoft.com","PattiF@M365x963508.onmicrosoft.com","LidiaH@M365x963508.onmicrosoft.com","MiriamG@M365x963508.onmicrosoft.com"
$Users = "IrvinS@M365x963508.onmicrosoft.com","JohannaL@M365x963508.onmicrosoft.com","DebraB@M365x963508.onmicrosoft.com"
ForEach ($Owner in $Owners){Add-TeamUser -GroupId $group.GroupId -User $Owner -Role Owner}
ForEach ($User in $Users){Add-TeamUser -GroupId $group.GroupId -User $User -Role Member -Verbose}

#Check that members are added, know that it could take up to 24 hours until they are actually added to Microsoft Teams
Get-TeamUser -GroupId $group.GroupId
Get-UnifiedGroupLinks NICDemo96 -LinkType owner
Get-UnifiedGroupLinks NICDemo96 -LinkType member

If you want an updated approach, you should check out the Book I am co-authoring that is update weekly by MVP Tony Redmond, to match the ever-changing Microsoft Cloud. The book is called Office 365 for IT-Pros and comes highly recommended.

One thought on “How I create Microsoft Teams in PowerShell, January 2018

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.