List all Sharepoint Document Libraries

jamorlando
jamorlando used Ask the Experts™
on
I'm looking for something I can run at the command line to list all document libraries within my site collection.  Is there a way to do this?  I did a browse of the STSADM.exe commands and there doesn't seem to be a way to list the document libraries.

Thanks,
Jamie
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
You'll probably need to write a custom Powershell script to do this.

Iterate through all your portals, then all your site collections and all sub sites. For each list, check the list type, if its a DocLib, output the result.

Here's a link to get you started - http://www.u2u.info/Blogs/karine/Lists/Posts/Post.aspx?ID=9
Thanks for getting me started.  Here's the code I wrote that produces the succesful output!


[void] [System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)
$siteurl = "http://sharepoint"
$mysite=new-object Microsoft.SharePoint.SPSite($siteurl) 
$mysite.AllWebs | foreach { $_.Lists | where {$_.BaseTemplate -eq "DocumentLibrary"} | format-table $_.Url, Title} | Out-File -FilePath D:\output.txt

Open in new window

Author

Commented:
Here's another version of the code using a * as a delimiter for parsing purposes.

[void] [System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)
$siteurl = "http://sharepoint"
$mysite=new-object Microsoft.SharePoint.SPSite($siteurl)

foreach ($CurrentSite in $mysite.Allwebs)
{
   foreach ($CurrentList in $CurrentSite.Lists)
   {
      Write-Host $CurrentSite.Url * $CurrentList.Title
   }
}

Author

Commented:
Sorry left my Document Library clause out of the nest loops. Here's what the loop should look like:

foreach ($CurrentSite in $mysite.Allwebs)
{
   foreach ($CurrentList in $CurrentSite.Lists)
   {
      if ($CurrentList.BaseTemplate -eq "DocumentLibrary")
      {
         Write-Host $CurrentSite.Url * $CurrentList.Title
      }
   }
}

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial