Windows 10 Powershell Invoke-WebRequest "Windows Security Warning"

Well, this is one big problem, in my opinion, that Microsoft should contact immediately. Steps to reproduce this:

powershell> Invoke-WebRequest "anywebsitewithcookies.com" (suppose, for example, microsoft.com)

It happens that you get the following warning: http://i.stack.imgur.com/TR023.jpg

Now it's just awful . Why Microsoft thinks this is acceptable is beyond me, but there was a workaround in Windows 8.1 . If you are logged in:

Control Panel> Internet Options> Privacy http://i.stack.imgur.com/OSLS3.jpg

You can set cookies that will be accepted all the time. This was the only way to get rid of this message and preserve the functionality of the DOM parsing. -UseBasicParsing is not a solution for me because I want to use the functionality returned by Invoke-WebRequest without basic parsing.

However, now in Windows 10, Microsoft decided to get rid of this slider for any reason: i.stack.imgur.com/jeNm3.jpg

This problem can be reproduced on every machine with Windows 10 and completely destroys how Invoke-WebRequest can be used in an environment with a silent script, since the script freezes and waits for a response to the dialogue . Is there a way to set Cookies for everyone, as in 8.1? I tried every setting in Internet Options in Windows 10 but nothing holds the key. I believe that they stopped using it and may have moved this setting to another place, but I can’t find it. Microsoft Edge also does not have many settings, so none of them were useful.

It just pisses me off. Any help would be greatly appreciated as it would create chaos in many environments.

+5
source share
2 answers

After several hours of searching, it turned out that although Windows 10 does not display the slider in Internet Properties, it still uses the corresponding registry key. So all you have to do is change:

HKEY_CURRENT_USER \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Internet Settings \ Zones \ 3 1A10 (Dword) to 0, where the values ​​indicate the same as on the slider from Windows 8.1: Block all cookies: 00000003 High: 00000001 Average value: 00000001 Medium: 00000001 Low: 00000001 Accept all cookies: 00000000

+3
source

Two small additions: Invoke-Webrequest does not seem to reread the registry settings in a PoSH session, so after changing the registry setting, close the PowerShell command prompt session and open it before starting IWR.

The second is just two commands that add the registry value (first) and then delete it (second) so you can put them in your scripts. Thus, you do not need to constantly run IE in the "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 
+3
source

All Articles