问题
I'm a bit confused with this issue! I'm building a bigger script and it was working in the ISE but not in a powershell console. I've managed to track it down to the [System.Uri]::EscapeDataString function which seems to be behaving differently between the different environments, for example in my powershell console () ' & ! are not being escaped, where as in the IDE they are all being escaped.
Am I missing something?
My test code:
[System.Uri]::EscapeDataString("/?:@%!$&'/*+,;=()")
ISE output:
%2F%3F%3A%40%25%21%24%26%27%2F%2A%2B%2C%3B%3D%28%29
Powershell Console output:
%2F%3F%3A%40%25!%24%26'%2F*%2B%2C%3B%3D()
Thanks!
回答1:
Here is the difference, per the source: [System.UriParser].GetField('s_QuirksVersion', [Reflection.BindingFlags] 'Static, NonPublic').GetValue($null)
.
I marked the answer as community wiki because it appeared in the comments, causing the question to appear in searches for unanswered questions.
来源:https://stackoverflow.com/questions/41959310/escapedatastring-having-differing-behaviour-between-powershell-ide-and-powershel