r/PowerShell • u/nkasco • Dec 10 '25
Invoke-WebRequest powershell.exe changes
Am I understanding correctly that windows powershell 5.1.x will soon see a mandatory change to provide user confirmation for any script using iwr without -usebasicparsing?
55
Upvotes
18
u/lan-shark Dec 10 '25
Looks like it. I'll probably also add
UseBasicParsingto our$PSDefaultParameterValuesas well. Off the top of my head, I can't think of a single script in our environment that runs in 5.1 and rawdogsInvoke-WebRequest, though I'm sure there is one or an in-house module somewhere that doesHere's the MS announcement
15
u/BlackV Dec 10 '25 edited Dec 10 '25
Thank gawd at least 1 tiny road bump I the
Or
Sorts of posts
Maybe Chris Titus will have to pull his socks up too
4
u/Gareth79 Dec 10 '25
Was just caught by this one, I have a PS script which is used to trigger a task on a different machine via. a web request, and it just appeared as running in Task Scheduler (it's kinda gross but that entire system is being replaced right now). Adding -UseBasicParsing is sufficient for me.
I suspect this will catch out a LOT of people and break random stuff in the coming days.
3
u/robp73uk Dec 10 '25 edited Dec 11 '25
Just to confirm having tested this.
In an interactive session, any usage of Invoke-WebRequest without UseBasicParsing results in the blocking prompt. There is no exemption for simple content or OutFile.
UPDATE: I’m wrong -OutFile does seem to be allowed.
In a non-interactive session, it’s now a terminating error.
This is pretty awful in my mind, though $PSDefaultParameterValues['Invoke-WebRequest'] = $true mitigates it.
Why they didn’t just change the default to UseBasicParsing and instead require people to opt-in with a new UseFullDOMParsing option I don’t know.
2
u/stopthatastronaut Dec 10 '25 •
It used to throw up a dialog on first use anyway, and tbh it needed to, because under the covers it was using iexplore when parsing.
We had a fleet of Windows Server Core machines in autoscaling groups and sending them a script to do an
iwrcould be a major headache…3
u/BlinkySLC Dec 10 '25 edited Dec 10 '25
This completely breaks a bunch of web scraping scripts I've written. What's the actual risk of running scripts from the DOM parser? My Powershell scripts are running with a service account without admin rights, the sites I were scraping were trusted (within reason, obviously anything can get hacked but these would not be easy targets). I would have assumed the page scripts would be running within a virtual browser sandbox that has very limited permissions to the actual system.
Why not just disable page scripts by default (with an option to override)? I think that would honestly still allow most of my scraping to work just fine. This is going to be a nightmare to rewrite.
1
u/purplemonkeymad Dec 10 '25
I can't think of times I actually needed the full parser. But then I'm also not usually downloading websites instead of talking to api endpoints.
1
u/whoamiagaindude Dec 10 '25
Thanks for that! I updated all occurrences on my git ;)
1
u/nascentt Dec 10 '25
Gotta love the lack of warning and no time to prepare leading right up to Christmas change freezes.
Fortunately I've used -usebasicparsing in 99.99% of scripts and automations I've made, but I've definitely seen 3rd party code I use call invoke-webrequest without it so I'm expecting things will definitely break.
Also there's absolutely a function or script I couldnt use usebasicparsing on because function wouldn't work otherwise so that'll definitely be breaking soon.1
1
u/CharcoalGreyWolf Dec 10 '25
I was reading about this. It seemed like they don’t halt if it’s for a file download, is that correct?
1
u/seaboypc Dec 10 '25
Wouldn't the malware scripters just add in the -usebasicparsing as well?
1
u/prizmaticend Dec 19 '25 edited Dec 21 '25
Reviving the thread a bit here, but I didn't see any others in the sub about this. For those that need a parser, would PowerHTML be recommended?
Edit: I ended up using PowerHTML and it didn't require too much change to code.