PowerShell Get URL of SharePoint List or Library

How do you get the URL of a SharePoint List or Library?

I had hoped it was as simple as $List.URL or something close to that.

Here is how I solved it, and please let me know if you have a better way!


Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$site = Get-SPweb "http://sharepointed.com/sites/blah"

$mList=$site.Lists["Tacos"]
 $ListURL = $site.url +"/"+ $mList.RootFolder.Url

$site.Dispose()

Update
Found a weird issue when trying to use $ListURL in a href tag. For some reason, if the list name had a space in it, anything after the first word would be dropped off in the link URL.

Example:
List Name: Real Big Taco
URL in href would be http://sharepointed.com/sites/blah/lists/Real

My fix:

 $ListURL = $site.url +"/"+ $mList.RootFolder.Url.ServerRelativeUrl.Replace(" ","%20")

Or as amac44 pointed out:
$list.ParentWeb.Url + ‘/’ + $list.RootFolder.Url

4 thoughts on “PowerShell Get URL of SharePoint List or Library

  1. Pingback: How to get SharePoint Online list url using Powershell? | CL-UAT

  2. Pingback: How to get SharePoint Online list url using Powershell? | Question and Answer

  3. Note in a subsite something like $list.ParentWeb.Url + ‘/’ + $list.RootFolder.Url will work better

Leave a Reply

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