Forum Discussion
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?
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
- Aravind_KalaiselvanCopper Contributor
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Using TLS1.2 connection resolved the problem for me. Try executing the above command before installation.
- arfmachBrass 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
- akb1985Brass ContributorWe 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.
- tommuonCopper Contributor
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
This fixed it for me as well
- ChrisB2020Copper Contributor
Setting TLS1.2 connection resolved the problem for me. Thank you so much.
- farismalaebSteel ContributorYes, there is an article which talk about this issue.
https://www.powershellcenter.com/2020/08/27/powershell-fix-warning-unable-to-resolve-package-source-https-www-powershellgallery-com-api-v2/
I struggle with this issue and the error is miss-leading.
- Reinier SPRUIJTBrass Contributor
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.
- CJ_ChaconCopper ContributorAdded it to $profile and works like a charm! Thanks!
- HAciliCopper Contributor
Hello Reinier,Reinier SPRUIJT
I have the same problem, please could you share with me the solution.
thank youu.
cordially
- SnehaTrivediCopper Contributor
Reinier SPRUIJT Thank you for the solution. It helped me as well.
- MaluksIron Contributor
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
- Reinier SPRUIJTBrass 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 LeeBrass Contributor
Have you tried:
Get-Module -Name PowerShellGet -ListAvailable | Install-Module
Have you tried the -Proxy/-ProxyCredential parameters? :)
- Reinier SPRUIJTBrass 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.
- Mitch CapelliCopper ContributorHi 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. - YannickBMICopper 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.
- MrPooleeCopper Contributor
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.