SharePoint Listing of all Lists in a Farm or a Site Collection using PowerShell

Here’s how you can view all the lists within a farm, even hidden lists like the TaxonomyHiddenList. Now, if you have a large farm, you obviously aren’t going to display all lists. You may, however, still want to display all lists in a site collection. That’s covered at the end of the post.

PS> foreach ($site in get-spsite) { 
foreach ($web in $site.AllWebs) { 
foreach ($list in $web.lists) 
{write-host $site.url - $web.Title - $list.Title 
} } } 

Great. Now let’s get something more. But what? What do we have to choose from? Well, here’s how to find that out.

And our output should look something like this:

You can run these 2 commands. The first stores all site objects into memory. The second then uses that memory to get the members of objects in memory.

PS C:\Users\david.frette> $sitelists = foreach ($site in get-spsite) {
 foreach ($web in $site.AllWebs) { 
foreach ($list in $web.lists) { 
$list } } }
PS C:\Users\david.frette> $sitelists | get-member

Then you’ll get this output! (Screen shots truncated)

What we see are the members of two different objects, the SPList and the SPDocumentLibrary.

Let’s choose a report that displays the Title, Hidden, and ItemCount. Our statement should look something like:

PS C:\Users\david.frette> $sitelists | select Title, Hidden, ItemCount

So that’s it in a nutshell: a quick listing of all lists in a farm. Now, if you just want a listing of all lists in a site, here’s what you want. Three commands.
The first sets a reference to your specific site collection.
The second places each list into memory (sitelist variable).
The third displays a report.

PS C:\Users\david.frette> 
$site = new-object Microsoft.SharePoint.SPSite("http://demo9/sites/BI")

PS C:\Users\david.frette> 
$sitelists =  foreach ($web in $site.AllWebs) { 
foreach ($list in $web.lists) { $list } }

PS C:\Users\david.frette> 
$sitelists | select Title, Hidden, ItemCount

Advertisements

One response to “SharePoint Listing of all Lists in a Farm or a Site Collection using PowerShell”

  1. Jade says :

    Very nice David..really appriciating.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: