Quantcast
Channel: Ryan Clark, Author at Mr. SharePoint
Viewing all articles
Browse latest Browse all 256

How to Decode a SharePoint Online URL Using Powershell

$
0
0

Need to decode a SharePoint URL?

In this guide, you will learn how to decode a SharePoint URL using PowerShell, as well as to get the reverse.

Let’s get started.

What is URL decoding?

URL decoding is particularly useful when dealing with web addresses that may contain special characters or spaces.

These encoded URLs become a bit complicated to read since there would be a lot of percent signs and numbers.

Decoding URLs in SharePoint is important for administrators and developers for the following reasons:

  • Better understanding of the structure of the site
  • Navigate its content programmatically with PowerShell
  • Ensure links are correctly formatted for users

The encoding replaces the unsafe ASCII character set with a percent sign and two hexadecimal digits.

Anyway, the ins and outs of this is usually for developers. But suffice it to say it’s important in custom scripts.

How to Decode a URL Using PowerShell

There is an easy way to decode a URL with PowerShell with the use of the UrlDecode method.

Let’s say you have this URL to decode:

https%3A%2F%2Fmrsharepoint.sharepoint.com%2FFinances%2FForms%2FAllItems.aspx

You can just use the following command:

[Net.WebUtility]::UrlDecode("https%3A%2F%2Fmrsharepoint.sharepoint.com%2FFinances%2FForms%2FAllItems.aspx")

After pressing enter, the method will convert the percent-encoded URL back to its original, human-readable format.

For this, the decoded URL is now back to the actual URL:

decode a sharepoint url using powershell

It is then easier for regular users to understand and navigate SharePoint Online sites and integrate with other scripts.

How to Encode a URL Using PowerShell

If you need to learn URL encoding, there is a method called UrlEncode that does the reverse process.

Let’s say you have this URL in its original form to encode:

https://mrsharepoint.sharepoint.com/Finances/Forms/AllItems.aspx

You can then use the following command:

[Net.WebUtility]::UrlEncode("https://mrsharepoint.sharepoint.com/Finances/Forms/AllItems.aspx")

After pressing enter, the method will transform the full URL into an encoded string.

Like this:

encode urls in sharepoint using powershell

That URL is then safe to use in web and network environments in SharePoint (like web requests, links, etc.).

Other Methods of Decoding a URL

The methods above are only if you specifically need to use PowerShell.

Usually, this happens when you have to weave the encoding/decoding into a larger script.

But if you want simpler tools, there are a lot of web apps like this one and that one that could encode/decode URLs.

Got any questions about using PowerShell to decode a SharePoint URL? If yes, leave a comment below.

For any business-related queries or concerns, reach out using the contact form here. I always reply.

The post How to Decode a SharePoint Online URL Using Powershell appeared first on Mr. SharePoint.


Viewing all articles
Browse latest Browse all 256

Trending Articles