Encoding and Decoding URLs in PowerShell

URLs in SharePoint are often filled with “%20” in place of blanks, and other substitutions. However there are times when the original clean URL is desired. The “%20” references are known as “encoded” URls. URL encoding replaces unsafe ASCII characters with a “%” followed by two hexadecimal digits.

URLs can only be sent over the Internet using the ASCII character set. However for emailing or auditing URLs, sometimes the decoded URL is desired.

Here’s how to Encode and Decode an URL in PowerShell:

$EncodedURL = [System.Web.HttpUtility]::UrlEncode($URL) 
$DecodedURL = [System.Web.HttpUtility]::UrlDecode($URL) 

Industry standard encoding is described in detail in: http://www.w3schools.com/tags/ref_urlencode.asp

2 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *