This package https://chocolatey.org/packages/server-jre8 is currently having to use .NET WebClient to download as for some reason if the script tries to set the Cookie using the Options collection, the cookie isn't maintained in the HTTP requests.
I wonder if this is because the cookie is added using the request url as the cookie domain, but in this case the server responds with a 302 that redirects to a different url before redirecting back to the download.
Maybe because the second request then doesn't include the cookie, the download fails.
Tracking with Fiddler, I can see that the WebClient call does send the cookie on the request following the redirect response.
This package https://chocolatey.org/packages/server-jre8 is currently having to use .NET WebClient to download as for some reason if the script tries to set the Cookie using the Options collection, the cookie isn't maintained in the HTTP requests.
eg.
I wonder if this is because the cookie is added using the request url as the cookie domain, but in this case the server responds with a 302 that redirects to a different url before redirecting back to the download.
Maybe because the second request then doesn't include the cookie, the download fails.
Tracking with Fiddler, I can see that the WebClient call does send the cookie on the request following the redirect response.
If Get-WebFile is used, the following is observed