Quick Start Encoding

suggest change
$url1 = [uri]::EscapeDataString("http://test.com?test=my value")
# url1: http%3A%2F%2Ftest.com%3Ftest%3Dmy%20value

$url2 = [uri]::EscapeUriString("http://test.com?test=my value")
# url2: http://test.com?test=my%20value
# EscapeUriString is obsolete. It leaves ":", "/", and "?" unencoded.

# On PowerShell 6 and later, System.Web.HttpUtility is not loaded by default.
$url3 = [System.Web.HttpUtility]::UrlEncode("http://test.com?test=my value")
# url3: http%3a%2f%2ftest.com%3ftest%3dmy+value

Note: HttpUtility.UrlEncode turns spaces into +. [uri]::EscapeDataString encodes them as %20.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents