MonthApril 2020

Managing Teams Private Channels With PowerShell

In the previous post we talked about the need to upgrade to TLS 1.2 to install PowerShell modules related to Office 365.

When using this method, specifically for Microsoft Teams, it will install a module where you won’t be able to execute commands related to private channels, such as the -MembershipType parameter when creating a new channel using the New-TeamChannel command.

To do this, we’ll need to install the Teams module from the PowerShell Test Gallery instead: https://www.poshtestgallery.com/

When going to that website, you’ll notice that the most known module there is the Microsoft Teams module, which as of now, had around 9,200 downloads in the last 6 weeks. To install this module, you would to remove the existing Teams Module if you already had it installed:

Uninstall-Module -Name MicrosoftTeams 

Then we’ll need to register the test gallery with PowerShell so we can use it later when we do installations, note the name of the gallery you choose to be used in PowerShell can be anything you like, for me I chose PSTG, short for PowerShell Test Gallery:

Register-PSRepository -Name PSTG-SourceLocation https://poshtestgallery.com -InstallationPolicy Trusted


Then we can install Teams module again:

Install-module -Name MicrosoftTeams -Repository PSTG -Force

Now you’re ready to go.

Common issues you might face:

1- If you get an error that the MicrosoftTeams module is already in use and you can’t remove it, just restart the PowerShell session.

2- If you get an error with something like:


The specified uri ‘https://www.poshtestgallery.com’ for parameter ‘SourceLocation’ is an invalid web uri. Please ensure that it meets the Web Uri Requirements.


Then it’s the same case as the previous post, where you need to set the PowerShell session to run on TLS 1.2, so commands will be like:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 

Register-PSRepository -Name PSTG -SourceLocation https://poshtestgallery.com -InstallationPolicy Trusted

April-2020 TLS Upgrade Needed for PowerShellGet

When trying to install any PowerShell module to work with Microsoft 365 (such as AzureAD v1, AzureAD v2, Teams, Exchange Online, SharePoint), I got the following issue:

WARNING: Source Location ‘https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7’ is not valid. PackageManagement\Install-Package : Package ‘PackageManagement’ failed to download. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21 + … $null = PackageManagement\Install-Package @PSBoundParameters + ~~~~ + CategoryInfo : ResourceUnavailable: (C:\Users\mderha…anagement.nupkg:String) [Install-Package], Exception + FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

The reason is that the PowerShell gallery has deprecated the support for TLS 1.0 and 1.1 in April 2020. So an upgrade needs to take place for the PowerShellGet module to support TLS 1.2 (or later version).

RESOLUTION

The following commands needs to be executed to update PowershellGet.

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12  
Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck 

Now you can install other modules for Teams, Azure, etc 

  • AzureAD v2:  Install-Module -Name AzureAD 
  • AzureAD v1:  Install-Module –Name MSOnline 
  • Teams:  Install-Module -Name MicrosoftTeams 
  • SharePoint:  Install-Module  Microsoft.Online.SharePoint.PowerShell 
  • Exchange Online: Install-Module -Name ExchangeOnlineManagement
  • Skype for business: https://www.microsoft.com/en-us/download/details.aspx?id=39366 

Here’s the list of modules related to Microsoft for reference:

To update a module:

Install-Module Microsoft.Online.SharePoint.PowerShell -force


AzureAD v1 still has richer commands, but AzureAD v2 will be the recommended one later. You can have both installed at the same time.