New Release for PowerShell Aficionados
On March 9, Microsoft updated the Teams PowerShell module to 1.0.4, and on March 11 they updated it again to 1.0.5. Microsoft updated the module to 1.0.5 after a decision was taken to release support for batch policy assignments for Teams education customers to assist in setting up classes for remote learning
You can grab the latest version from the PowerShell gallery. If you’ve already installed a previous version of the module, you can update it by running this command from a PowerShell session when signed in as an administrator:
Update-Module -Name MicrosoftTeams -RequiredVersion 1.0.5
As always, the recommendation is to use the latest version of the Teams module to make sure that you take advantage of the bug fixes made by Microsoft.
Upgrades in Teams PowerShell Module 1.0.4/1.0.5
Among the upgrades in 1.0.5 are:
- The Get-Team cmdlet is a little faster at fetching teams. Microsoft says that the cmdlet is “more resilient” when used in tenants with large number of Teams. No improvements have been made on giving Get-Team better filtering capabilities to reduce the number of teams that must be processed client-side.
- When you add a new owner to a team with the Add-TeamUser cmdlet, it now adds the user as both an owner and as a member. This avoids the need to run the cmdlet twice to add users in both roles, as was previously necessary.
- The Remove-TeamUser cmdlet is removes a member from a team. Microsoft has updated the cmdlet to make sure that if an owner is removed, they are also removed as a member. The exception is when the owner is the last owner for the team. In this scenario, Teams doesn’t allow you to remove the owner until another member is assigned as an owner.
- The new RetainCreatedGroup parameter is added to the New-Team cmdlet. The default is $False, meaning that if the New-Team cmdlet fails for any reason to create a new team, the cmdlet should also remove the underlying Office 365 group. Generally it’s best to let Teams clean up if problems occur when creating a new team, but if you want to keep the group after a New-Team failure, run New-Team -RetainCreatedGroup:$True.
You shouldn’t have to change anything in scripts after upgrading the Teams PowerShell module to V1.0.5.
Beta Teams PowerShell Module
Microsoft also publishes a beta version of the Teams module in the PSGalleryInt repository to allow tenants to have early access to cmdlets in development.
You can run the production and beta versions of the Teams module on the same workstation, but you must register PSGalleryInt as a PowerShell repository before you can find and install the beta module. These commands show how to register PSGalleryInt and find the beta module. As you can see, the production version is 1.0.5 while the beta is at 1.0.21.
Register-PSRepository -Name PSGalleryInt -SourceLocation https://www.poshtestgallery.com/ -InstallationPolicy Trusted
Find-Module microsoftTeams | Format-Table Name, Version, Repository
Name Version Repository
---- ------- ----------
MicrosoftTeams 1.0.5 PSGallery
MicrosoftTeams 1.0.21 PSGalleryInt
Teams and the Graph
The Teams PowerShell module is limited in terms of the properties it makes available. Sometimes you need to use Microsoft Graph API calls to supplement what’s possible with the Teams cmdlets. This post describes an example of using a combination of PowerShell and Graph calls to report the email addresses assigned to Teams channels. If you use Graph calls, remember that the Graph throttles the amount of data returned for any call to restrict the use of resources. For this reason, you must use pagination to fetch all data when more than 100 objects (like teams) are available.
The Office 365 for IT Pros eBook contains many examples of how to use PowerShell to work with Teams and Office 365 Groups. We’ll update our text on this topic in the April update for the 2020 edition. Stay tuned.