SOLVED

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

Brass Contributor

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-... 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?

22 Replies

Please try to install the latest PowershellGet module as described here https://www.powershellgallery.com/packages/PowerShellGet/1.6.5 and try you actions again.

 

You can try both Azure Ad versions 

Install-Module AzureAD or Install-Module AzureADPreview

Have you tried the -Proxy/-ProxyCredential parameters? :)

@Arūnas Malūkas, 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?

@Vasil Michev, 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.

Have you tried:

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

Thank you for the tip @Thomas Lee, when I run Get-Module -Name PowerShellGet -ListAvailable | Install-Module I get 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.

 

Is this expected given that the get-module -ListAvailable match for PowerShellGet did list a path in C:\Program Files\WindowsPowerShell?  Also, it part of the issue that get-module and get-psrepository don't have parameters to set a proxy?  As I mentioned before, I did have set my proxy using NetSH WinHTTP Set Proxy proxy-server="my.proxy.server".

 

I'm running out of options running with this network configuration, as the proxy seems to be the issue.  I have managed to install the module on another device outside the network.

Whoops - my bad - a typo in my suggestion.

Instead of Get-Module -list, it should have been Find-Module PowerShellGet  | Install-module

Hi Reinier,

Are you able to make a connection through Powershell with Msol service.

You may find it easier, using the method outline in the following article.
https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-office-365-powershell
The same method can be used to connect to and install AzureAD, which is covered in the article.

Thank you all for your help.  Solution found!

 

https://blogs.technet.microsoft.com/keithmayer/2016/01/06/quick-tip-using-azure-powershell-with-web-... 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.

Added it to $profile and works like a charm! Thanks!

@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.

Hello Reinier,@Reinier SPRUIJT 

I have the same problem, please could you share with me the solution.

thank youu.

 

cordially 

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

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

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

 

This fixed it for me as well

best response confirmed by Adam Fowler (Iron Contributor)
Solution

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

@Reinier SPRUIJT  Thank you for the solution. It helped me as well.

 

@Aravind_Kalaiselvan 

Setting TLS1.2 connection resolved the problem for me.  Thank you so much.

Yes, there is an article which talk about this issue.
https://www.powershellcenter.com/2020/08/27/powershell-fix-warning-unable-to-resolve-package-source-...
I struggle with this issue and the error is miss-leading.
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.
1 best response

Accepted Solutions
best response confirmed by Adam Fowler (Iron Contributor)
Solution

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

View solution in original post