DevOps | Scripts | Automation

PowershellTroubleShooting

How to resolve: Unable to find repository with Source location in PowerShell?

Hello there,

Last week I was working on one of my PowerShell scripts which was supposed to install some Azure Modules and run our commands, and it worked all fine in all the environments but for the one environment, I have faced this issue “Unable to find repository with Source location“. It was strange because when I ran Get-PSRepository, the output was Null. Then I ran this command, Get-PackageProvider -ListAvailable. The output was also null.

Image

Although enabling TLS1.2 was added in the script already, I ran it again manually.

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

I came to this MS blog and had attempted all commands given but none of them worked.

https://docs.microsoft.com/en-us/answers/questions/257840/powershell-unable-to-find-module-providers-powersh.html

Finally, on the github site, One of the users has mentioned that it was the FIPS security settings was enabled in the security policy and which prevents MD5 hash to run and most of the PowerShell commands are compliant with the MD5 hash protocol.

https://github.com/OneGet/oneget/issues/195

Check if the FIPS enabled and Disable it.

So if none of the above attempts mentioned in the MS link works then check if the computer has FIPS enabled using below command.

[System.Security.Cryptography.MD5]::Create()

If the above command gives an error then the FIPS is enabled and it can’t run the commands that uses MD5 hash.

Alternate option to check if the FIPS enabled is to check security settings in Secpol.msc.

Security Settings -> Local Policies -> Security Options -> Use the FIPS compliant algorithm..

To disable it, click on Disabled and click Apply and then reboot the computer.

Another option to verify is by checking registry settings at the below location.

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy

If the Enabled key is set to 1 then the FIPS is enabled. You can set it to 0 to disable it and then reboot the computer.

Once FIPS algorithm is disabled, you can run Get-PSRepository or Get-PSProvider -ListAvailable command and it should work.