Can't install Exchange Online PowerShell V2 module

Ali Price 1 Reputation point
2021-11-24T22:51:44.563+00:00

I'm trying to enable modern authentication for an O365 tenant, and then instructions say to import the Exchange Online Management module. I don't have that module, so those same instructions say to install it by using

Install-Module -Name ExchangeOnlineManagement -RequiredVersion 2.0.5

But then I get this error

WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
PackageManagement\Install-Package : No match was found for the specified search criteria and module name
'ExchangeOnlineManagement'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], E
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Just in case I did also run this to check

Get-PSRepository

And the result was

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2

And that seems correct. So does anybody know why it's not working.

Thanks!

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 45,091 Reputation points
    2021-11-25T03:44:49.537+00:00

    You may have a problem with TLS: powershell-fix-warning-unable-to-resolve-package-source-https-www-powershellgallery-com-api-v2

    Does this work, or do you get an error?

    Invoke-WebRequest 'https://www.powershellgallery.com/api/v2/'
    
    0 comments No comments

  2. Ali Price 1 Reputation point
    2021-11-25T18:16:26.837+00:00

    You are correct it was a TLS issue in the end. The solution was to force a higher version of TLS using:

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    
    0 comments No comments