Using any of the PowerShellGet cmdlets, if -Repository PSGallery is specified and is unavailable due to network or similar issues, user must use a new console session for the command to succeed.
I was having networking issues could not reach the PowerShell Gallery using Find-Module from PowerShellGet v1.1.2.0. I specified -Repository PSGallery because I test with other galleries.
I received the error "PowerShell Gallery is currently unavailable. Please try again later." I used a browser, was eventually able to connect to the Gallery website.
After that, going back to the same PS session, I got the same message every time I re-ran the command. I tried opening a new PS Session and it worked. Turns out to be due to a perf optimization only for PSGallery, and only if the repository is specified.
Expected Behavior
When the request times out, and I repeat the command, it should try to connect again immediately.
Re-running the command should be treated as a discrete occurrence, regardless of what Repo is specified. Networking & website connection errors happen intermittently for a variety of reasons.
Once the connection can be established, the command should work.
Current Behavior
These results can be reproduced by disconnecting network & wifi connections, then running two commands:
Find-Module PowerShellGetFind-Module PowerShellGet -Repository PSGallery
The first will fail with an error message beginning " No match found". The second will fail with the error message "PowerShell Gallery is currently unavailable"
Reconnect the network, & repeat the 2 commands
The first command will succeed.
The second command will fail with the same error, indefinitely.
Note that the module specified does not matter.
Possible Solution
There is a special check in place for when the user specifies using PSGallery as the PSRepository. This should be removed.
Using any of the PowerShellGet cmdlets, if -Repository PSGallery is specified and is unavailable due to network or similar issues, user must use a new console session for the command to succeed.
I was having networking issues could not reach the PowerShell Gallery using Find-Module from PowerShellGet v1.1.2.0. I specified -Repository PSGallery because I test with other galleries.
I received the error "PowerShell Gallery is currently unavailable. Please try again later." I used a browser, was eventually able to connect to the Gallery website.
After that, going back to the same PS session, I got the same message every time I re-ran the command. I tried opening a new PS Session and it worked. Turns out to be due to a perf optimization only for PSGallery, and only if the repository is specified.
Expected Behavior
When the request times out, and I repeat the command, it should try to connect again immediately. Re-running the command should be treated as a discrete occurrence, regardless of what Repo is specified. Networking & website connection errors happen intermittently for a variety of reasons.
Once the connection can be established, the command should work.
Current Behavior
These results can be reproduced by disconnecting network & wifi connections, then running two commands:
Find-Module PowerShellGet
Find-Module PowerShellGet -Repository PSGallery
The first will fail with an error message beginning " No match found". The second will fail with the error message "PowerShell Gallery is currently unavailable"
Reconnect the network, & repeat the 2 commands The first command will succeed. The second command will fail with the same error, indefinitely. Note that the module specified does not matter.
Possible Solution
There is a special check in place for when the user specifies using PSGallery as the PSRepository. This should be removed.
Context
Your Environment