Forum Discussion

Reinier SPRUIJT's avatar
Reinier SPRUIJT
Brass Contributor
Jun 11, 2018

Trying to Install-Module AzureAD but Get-PSRepository "WARNING: Unable to find module repositories."

I am running PSVersion 5.1.16299.431 and have set my proxy using NetSH WinHTTP Set Proxy proxy-server="my.proxy.server"

 

I would like to "Install the preview version of the Azure Active Directory Module for Windows PowerShell" as per https://support.office.com/en-gb/article/Manage-who-can-create-Office-365-Groups-4c46c8cb-17d0-44b5-9776-005fced8e618.  However, on running Install-Module AzureAD I see "PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'AzureAD'. Try Get-PSRepository to see all available registered module repositories."

 

I can run Register-PSRepository -Default without issue but when I run Get-PSRepository I am faced with "WARNING: Unable to find module repositories."

 

I have been able to run update-help, so I assume I can get online ok.

 

Finally, I tried to Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/
-Proxy my.proxy.server but see the message, "Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable.  Please try again later."

 

Can someone please advise what I need to do to be able to successfully Install-Module AzureAD?

  • arfmach's avatar
    arfmach
    Jun 18, 2020

    I followed this article, and the "Microsoft way" didn't work. I needed to execute the second block of commands:

     

    [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
    Register-PSRepository -Default -Verbose
    Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
  • [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 

    Using TLS1.2 connection resolved the problem for me. Try executing the above command before installation. 

    • arfmach's avatar
      arfmach
      Brass Contributor

      I followed this article, and the "Microsoft way" didn't work. I needed to execute the second block of commands:

       

      [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
      Register-PSRepository -Default -Verbose
      Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
      • akb1985's avatar
        akb1985
        Brass Contributor
        We noticed an issue while installing Microsoft 365 PowerShell modules on some of the servers in the environment. Get-PSRepository did not return any value on these servers. This solution helped to register repositories and then we could successfully install all Microsoft 365 PowerShell modules in the servers.
    • tommuon's avatar
      tommuon
      Copper Contributor
      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

       

      This fixed it for me as well

  • Thank you all for your help.  Solution found!

     

    https://blogs.technet.microsoft.com/keithmayer/2016/01/06/quick-tip-using-azure-powershell-with-web-proxy-and-fiddler/ at Step 2 (Optional) – Add Proxy Credentials to Script:

     

    To use Windows credentials for proxy authentication, you can add …
    [System.Net.WebRequest]::DefaultWebProxy.Credentials =  [System.Net.CredentialCache]::DefaultCredentials

     

    ...and when I added that in a new PowerShell session, Get-PSRepository shows the expected:

     

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

     

    ...and Install-Module AzureADPreview works, so obviously a proxy issue all along.

    • Reinier SPRUIJT's avatar
      Reinier SPRUIJT
      Brass Contributor

      Maluks, thank you for the suggestion.  When I run Get-Module -Name PowerShellGet -ListAvailable | Select-Object -Property Name,Version,Path it results in the following output:

      Name          Version Path
      ----          ------- ----
      PowerShellGet 1.0.0.1 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PowerShellGet.psd1

      However, when I then run Install-Module PowerShellGet -Force I get the output:


      PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PowerShellGet'. Try Get-PSRepository to see all available registered module repositories.

       

      Also, when I run Save-Module -Name PowerShellGet -Path "c:\mydir" I get output:

       

      PackageManagement\Save-Package : No match was found for the specified search criteria and module name 'PowerShellGet'. Try Get-PSRepository to see all available registered module repositories.

       

      Any other way to Install-Module AzureAD you can suggest?

      • Thomas Lee's avatar
        Thomas Lee
        Brass Contributor

        Have you tried:

        Get-Module -Name PowerShellGet -ListAvailable | Install-Module

    • Reinier SPRUIJT's avatar
      Reinier SPRUIJT
      Brass Contributor

      VasilMichev, yes I did also try Install-Module AzureAD -proxy "my.proxy.server" with output:

       

      PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'AzureAD'. Try Get-PSRepository to see all available registered module repositories.

  • YannickBMI's avatar
    YannickBMI
    Copper Contributor

    Reinier SPRUIJTIn my case, I removed "Automatically detect setting Local Area Network (LAN) Settings" and Protected Mode from IE to install and use the module. I was on a server.

  • MrPoolee's avatar
    MrPoolee
    Copper Contributor

    Reinier SPRUIJT 

     

    For me, I eventually found that the Execution Policy was set to Restrict.  I changed this to Bypass (Set-ExecutionPolicy Bypass), then was able to see that the see the repository (Get-PSRepository).

     

    Then I just had to trust the PSGallery (Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted).

     

    After that, I had no further problems.

     

Resources