SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Working on a script that will dump out all of the lists and libraries in a site, I found the script on Mike Smith's Blog:

I threw in a couple prompts for user input but otherwise it's still the same's great but i need to be able to seperate what is a list and what is a library....does anyone know how to tweak this script to seperate the two types of objects that instead of one long list of lists and libraries it shows them grouped by type?

Here is the code:

$sitec = Read-Host 'Enter Site Collection (ex:'
$subsite = Read-Host 'Enter Sub-Site(ex: departments or ENTER for "root")'
$site = Get-SPSite $sitec
$web = $site.OpenWeb("$subsite")
write-host "Site: " + $
write-host "Web: " + $
$web.lists | Format-Table title,id -AutoSize


share|improve this question
up vote 5 down vote accepted

You should try

$libraries = $web.lists | Where-Object { $_.BaseType -Eq "DocumentLibrary" } 
$libraries | Format-Table title,id -AutoSize

$lists = $web.lists | Where-Object { $_.BaseType -Eq "GenericList" } 
$lists | Format-Table title,id -AutoSize

The key here, is the SPList.BaseType property.

As decribed in the SPBaseType Enumeration, there are other base type you may take into account.

share|improve this answer
This was just what i needed and i appreciate the help Steve! – Jacob A Dec 18 '12 at 16:18
You are welcome. PowerShell is powerful tool for some SharePoint operations. If you understand its philosophy, it can help you in a lot of situations :) – Steve B Dec 18 '12 at 16:23
Agreed! I was able to expand the script with your help but also to include a transcript option as well so that it would output the ID's. Many thanks again! Cheers! – Jacob A Dec 18 '12 at 16:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.