Tag Archives: pscore

Register-PSRepository fails on Powershell Core when running behind a corporate proxy

Trying to register a psrepository behind a corporate proxy fails on Powershell Core.

The error you receive is:

Running the same on Windows Powershell 5.1 works.
Now, let see why it’s not working on Powershell Core.

Trying to find more details about the error message:

Let’s look at the function inside the module where the error is triggered (bonus tip on how to jump directly to the line number)

The error message is misleading, as it turns out the part that is failing is this one:

We know the endpoint location is valid, so that means we cannot pass through the proxy.
Digging around the internet led me to this GitHub issue.

Apparently, .NET Core is not respecting proxy in some cases.

The recommended workaround from Steve Lee is to set

or to create

Turns out our little problem is now fixed and the Register-PSRepository command runs successfully.

I hope this post will save you some time in case you run into the same issue.

Voilà!