Alright this is one big problem in my opinion that Microsoft needs to address immediately. Steps to reproduce this:
powershell> Invoke-WebRequest "anywebsitewithcookies.com" (Let's do microsoft.com for example)
What happens is that you get the following warning: http://i.stack.imgur.com/TR023.jpg
Now this is just horrible. Why Microsoft thinks this is acceptable is beyond me, however in Windows 8.1 there was a workaround. If you went into:
Control Panel > Internet Options > Privacy http://i.stack.imgur.com/OSLS3.jpg
You could set cookies to be accepted all the time. This was the only way to get rid of this message and still retain DOM parsing functionality. -UseBasicParsing isn't a solution for me, because I want to use the functionality of what Invoke-WebRequest returns without basic parsing.
However now in Windows 10 Microsoft decided to get rid of this slider for whatever reason: i.stack.imgur.com/jeNm3.jpg
This problem can be reproduced on every Windows 10 machine and completely destroys how Invoke-WebRequest can be used in a silent scripting environment, because the script hangs and waits for the dialog to be answered. Is there a way to still set Cookies to be accepted for all like in 8.1? I tried every setting in Internet Options in Windows 10, but nothing holds the key. I believe they stopped using it and perhaps moved that setting elsewhere, but I can't find it. Microsoft Edge doesn't have many settings either, so none of them were helpful.
This is just infuriating. Any help would be highly appreciated, as this will create quite a chaos in many environments.
Two small additions: Invoke-Webrequest seems not to re-read the Registry settings within a PoSH session, so after changing the Registry setting, close the PowerShell command session and re-open it before running IWR.
The second is just two commands that will add the Registry value (first one) and delete it afterward (second one) so you can put them in your scripts. That way, you needn't constantly run IE in "accept all cookies" mode.
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /t REG_DWORD /v 1A10 /f /d 0
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v 1A10 /f
After hours of searching I found out that even though Windows 10 doesn't display the slider in Internet Options, it still uses the registry key that corresponds to it. So all you have to do is change:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3 1A10 (Dword) to 0, where values indicate the same as on the slider from Windows 8.1: Block All Cookies: 00000003 High: 00000001 Medium High: 00000001 Medium: 00000001 Low: 00000001 Accept all Cookies: 00000000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With