[X] Make sure you are able to repro it on the latest version
[X] Search the existing issues.
Steps to reproduce
Recently, I got one issue from customer. We find the issue is caused by Ping-Endpoint (functions in PowershellGet module, PSModule.psm1 ) returns 403 or 405 randomly when execute Register-PSRepository.
1- In the environment, we will see in verbose message, there are several ping-endpoint results and for the last one, it returns 403.
2- At this point, if we check psrepositories.xml file (C:\Users\\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet), we will see the "sourcelocation" is null.
3- For the following attempts to register a repository it will fail with the same error.
4- In my local lab, I forcely change the last ping-endpoint result to 403/405 in psmodule.psm1 and the same result would be reproduced that "sourcelocation" in psrepositories.xml is null but the error message is a little bit different.
5- To resolve this issue, currently, the only way seems to delete the psrepositories.xml
6- In the PowershellGet version 2.1.0, it is has already handled 200, 401 and 407. Will it be possible to add 403 and 405 also? Appreciate your inputs.
Prerequisites
Steps to reproduce
Recently, I got one issue from customer. We find the issue is caused by Ping-Endpoint (functions in PowershellGet module, PSModule.psm1 ) returns 403 or 405 randomly when execute Register-PSRepository.
1- In the environment, we will see in verbose message, there are several ping-endpoint results and for the last one, it returns 403.
2- At this point, if we check psrepositories.xml file (C:\Users\\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet), we will see the "sourcelocation" is null.
3- For the following attempts to register a repository it will fail with the same error.
4- In my local lab, I forcely change the last ping-endpoint result to 403/405 in psmodule.psm1 and the same result would be reproduced that "sourcelocation" in psrepositories.xml is null but the error message is a little bit different.
5- To resolve this issue, currently, the only way seems to delete the psrepositories.xml
6- In the PowershellGet version 2.1.0, it is has already handled 200, 401 and 407. Will it be possible to add 403 and 405 also? Appreciate your inputs.
PowerShell Gallery | PSModule.psm1 2.1.0
Write-Debug -Message "Ping-Endpoint: location=$Location, statuscode=$statusCode, resolvedLocation=$resolvedLocation"
if((($statusCode -eq 200) -or ($statusCode -eq 401) -or ($statusCode -eq 407)) -and $resolvedLocation) { return $resolvedLocation }
Expected behavior
Actual behavior
Error details
Environment data
Version
Powershell version 5.1, PowershellGet version 1.0.0.1
Visuals
No response