Use PowerShell to identify a list from an ID in SP2010

Here’s a little bit of PowerShell that I thought I’d share. I had an issue this week were I was presented with a helpful ‘List does not exist error’.

List Does Not Exist Error

But no indication as to which list?! After checking the obvious things (master page checked in etc), I thought it would be just easiest to open up the ULS logs and see what was going on.

The ULS logs (using the great ULS Viewer) gave me the ID of a list that it couldn’t find. As I don’t happen to know the GUIDs of the all the lists in my solution… step forward PowerShell.

This little one-liner iterates through each web in a given site collection, and for each web checks to see if any of the lists have a matching ID. The single result is output to a table for simplicity.

Get-SPSite http://sp2010 | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq “LIST-ID-GOES-HERE”} | ft Title, ParentWebURL, RootFolder

The screenshot below shows this in action:

PowerShell Get List By ID

[And in case any of you were wondering, my issue turned out to be a colleague working with a Data Form Web Part, and SharePoint Designer had helpfully added an unneeded reference to the pages library it was initially built on.]

share and enjoy
  • Print
  • Twitter
  • Digg
  • StumbleUpon
  • Yahoo! Buzz
  • Google Bookmarks
  • Facebook

3 comments to Use PowerShell to identify a list from an ID in SP2010

  • […] All of this was getting a bit much and I kept editing the $web to point to different url’s to try and track down the list (it wasn’t in this web!). This lead me to start writing recursion with nested for-each loops and the like. Suddenly I remembered that I wasn’t working with the Object Model in a C# app, but I was using PowerShell and have access to pipe binding! So a quick Google lead me to this answer: […]

  • Chilly

    How about try this.
    Step 1: Grab the web object
    $web = get-spweb -identity “Web url”

    Step 2: Filter on List GUID object
    $list = $web.lists[[GUID](“ID of the list”)]

    This works for me. Give it a whirl

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>