5

How can I perform a check if a document library already exists using Powershell in SharePoint 2010?

1 Answer 1

7

Something like this:

$w = get-spweb "<webURL>"
$list = $w.Lists.TryGetList("<Title of the list>")
if($list -ne $null)
{
    # The list already exists
}

Replace <webURL> and <Title of the list> with your actual values

2
  • And is there also a way to check that it is a document library type list and not just a normal list? Commented Nov 5, 2014 at 11:42
  • 2
    On the list you can call $list.BaseType. It will return DocumentLibrary for libraries and GenericList for lists Commented Nov 5, 2014 at 11:43

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.