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.
Pingback: Managing Teams Private Channels With PowerShell | SharePoint Thoughts