How can I perform a check if a document library already exists using Powershell in SharePoint 2010?
1 Answer
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
-
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
-
2On the list you can call
$list.BaseType
. It will returnDocumentLibrary
for libraries andGenericList
for lists Commented Nov 5, 2014 at 11:43