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?motionpotion– motionpotion2014-11-05 11:42:10 +00:00Commented Nov 5, 2014 at 11:42
-
2On the list you can call
$list.BaseType. It will returnDocumentLibraryfor libraries andGenericListfor listsRobert Lindgren– Robert Lindgren2014-11-05 11:43:08 +00:00Commented Nov 5, 2014 at 11:43