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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.