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: http://techtrainingnotes.blogspot.com/2011/06/finding-sharepoint-guids-using.html

I threw in a couple prompts for user input but otherwise it's still the same code. It's great but I need to be able to separate what is a list and what is a library. Does anyone know how to tweak this script to separate the two types of objects reported, so 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: http://yours.yourdomain.com)'
$subsite = Read-Host 'Enter Sub-Site(ex: departments or ENTER for "root")'
$site = Get-SPSite $sitec
$web = $site.OpenWeb("$subsite")
write-host "Site: " + $site.id
write-host "Web: " + $web.id
$web.lists | Format-Table title,id -AutoSize

1 Answer 1


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.

  • This was just what i needed and i appreciate the help Steve!
    – Jacob A
    Commented Dec 18, 2012 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
    Commented Dec 18, 2012 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
    Commented Dec 18, 2012 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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