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

I want to make some changes to all of the document libraries in a site collection, but not make changes to any other lists. In PowerShell, how can I check whether a list is a document library, or a different kind of list?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

To see the all the lists in a site, and if they are a document library or not, this PowerShell script should be helpful:

$web = get-spweb http://<your site url>
$lists = $web.lists
foreach ($list in $lists) {
   write-host $list.title, "(", $list.BaseType, ")"
}
$web.dispose()

I ran this on one of my sites, and it returned a mix of "GenericList" and "DocumentLibrary" as the BaseType property.

You can also look at the property $list.BaseTemplate along with $BaseType to narrow down the number of system generated document libraries that are returned.

-LB

share|improve this answer
    
I chose this as the answer because it was very helpful to have all of the lists and their types as output. Quick note though, in the first line "get-spweb" should not have a dollar sign in front of it. –  LCountee Nov 21 '11 at 20:01
add comment

Assuming you have instance of SPList in powershell, the BaseType of list would be SPBaseType.DocumentLibrary for list of type document library.

So that check may look like

if (oListObject.BaseType -eq [Microsoft.SharePoint.SPBaseType]::DocumentLibrary) {

}

share|improve this answer
add comment

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.