Last Update: Sep 04, 2024 | Published: Nov 06, 2018
Given that the Teams and Skype for Business Online Admin Center recently introduced support for team management, it is unsurprising that Microsoft has refreshed the Teams PowerShell module. You can now download version 0.9.5 from the PowerShell Gallery).
In terms of the administrative control over Teams, the module has improved steadily from the first release and is now capable of handling most of the administrative operations available in the Teams and Skype for Business Online Admin Center. Cmdlets are available to create teams (including a team for an existing Office 365 group), list all teams in the tenant, update settings for teams, and create new channels. Because the module is still evolving, some change is inevitable before the final release. Even with this warning, you can depend on the current release for production use.
Before you can use the Teams module, you must download it from the PowerShell gallery and then install the module on your PC. To update to the latest release, use PowerShell with administrator permissions and run the following commands to remove the previous version and download and install the latest module.
Uninstall-Module -Name MicrosoftTeams Install-Module -Name MicrosoftTeams -Repository PSGallery
If you haven’t ever installed the module, you naturally don’t need to remove it.
After installing the module, you run the Connect-MicrosoftTeams cmdlet to connect to the Teams service.
Up to 0.9.5, the Get-Team cmdlet suffered from the severe restriction of only being able to return a set of teams that the logged-in user was a member of. This is a problem because administrators often want to work with teams that they don’t belong to. Now, if you run Get-Team without any parameters, it returns the full set of teams in the tenant.
Apart from being more convenient, Get-Team is much faster at retrieving a list of teams than any other method such as running Get-UnifiedGroup and then trying to figure out what Office 365 Groups are team-enabled.
If you want to retrieve a list of teams that the currently logged-in user belongs to, pass their User Principal Name via the User parameter:
Get-Team -User [email protected]
Get-Team is fast, but it is a very simple cmdlet that returns just three values for a team:
The group identifier is the most important value. It is a GUID that uniquely identifies a team and is used as the input to most of the other cmdlets in the Teams module. For example, to add a new member to a team, we run the Add-TeamUser cmdlet and pass the group identifier and the User Principal Name for the new member:
Add-TeamUser -GroupId 72ee570e-3dd8-41d2-bc84-7c9eb8024dd4 -User "[email protected]" -Role Member
Given that Teams depends on Office 365 Groups and Azure Active Directory, it’s likely that you will want to access the cmdlets to retrieve some information such as the extended properties for Office 365 Groups. You can use the group identifier to interact with these cmdlets.
For example, to get information from Azure Active Directory about the team membership, input the group identifier as the object identifier for Get-AzureADGroupMember:
Get-AzureADGroupMember -ObjectId 129bfa64-3d11-4d6f-b9a9-6c20ec03bd8d
To use the group identifier with the Office 365 Groups cmdlets, pass it as the identity. For example, here’s how to get the same membership using Get-UnifiedGroupLinks:
Get-UnifiedGroupLinks -LinkType Member -Identity 129bfa64-3d11-4d6f-b9a9-6c20ec03bd8d
The Get-Team cmdlet does not include a Filter parameter to select a subset of teams, probably because the cmdlet returns such a limited set of properties. However, you can trade some of the performance by applying a client-side filter to the display name or description properties to find specific teams. For example:
Get-Team | ? {$_.DisplayName -Like "*Office*"} | Format-Table DisplayName, Description
We can combine a filtered lookup for a specific team to return its identifier and use that value to fetch information from Azure Active Directory or the Office 365 group:
$Group = (Get-Team | ? {$_.DisplayName -eq "Office 365 Questions"} | Select GroupId) Get-UnifiedGroup -Identity $Group.GroupId
The lack of good filtering for Get-Team doesn’t matter so much when your tenant only has a few hundred teams. It becomes more of an issue as the number of teams increases. It would be nice if Microsoft supported server-side filtering for the cmdlet – and added a few extra properties to use with filtering. For example, to select teams managed by a certain person, or those with guest users, or those marked with a specific classification.
It’s good to see the Teams PowerShell module make progress and we can expect further updates as the module makes its way to generally available status. What’s not so good is that the full spectrum of Teams management through PowerShell is split across three modules: Exchange Online, Skype for Business Online, and Teams. This is because different engineering groups are responsible for each module and it’s unlikely that this situation will change in the short term. With that in mind, it would sure be nice if a connection to any of these modules offered the option to bring in the other modules.