Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 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 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
$web.Dispose()
$site.Dispose()

Cheers!

share|improve this question

1 Answer 1

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

 
discard

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.