4

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?

6

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

  • 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. – LFurness Nov 21 '11 at 20:01
10

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) {

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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