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 "" -owner -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

#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 = "","","",""
$Users = "","",""
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.

Share a single document with external user in Microsoft Teams

Guest Access in Microsoft Teams is a great way to collaborate with external Office 365 users in chat, files and existing tabs. Sometimes you may want to collaborate on a single document with an external user without giving them access to your entire team. Turns out, this is disabled by default.

You need to enable it via SharePoint PowerShell, here is how

  • Connect to SharePoint Online via PowerShell
  • list all site collections for your Office 365 Groups and Teams
    • Get-sposite -template GROUP#0 -includepersonalsite:$false
  • Copy the URL you want to change
  • Run the following command to make the change
    • Set-SPOSite -Identity -SharingCapability ExternalUserAndGuestSharing
    • The new sharing capability is called ExternalUserAndGuestSharing
      • External user sharing (share by email) and guest link sharing are both enabled
    • The default value is ExistingExternalUserSharingOnly
      • Allow sharing only with the external users that already exist in your organization’s directory

Now you are able to in to a document, click the sharing button, choose specific users and invite those you want to collaborate with on this specific document. It is important that you choose the option “only the people you specify”, then and only then will they be able to work with the document in their desktop client