Delete a SharePoint List or Document Library via Powershell

 

$listName = "<Document Library Name>"
$spWeb = Get-SPWeb <Absolute Web Url>
$list = $spWeb.Lists[$listName]
if($list -ne $null)
{
  $list.Delete()
  write-host $listName "was deleted" -foregroundcolor Green
}
else
{
  write-host $listName "doesn't exist on" $spweb.url -foregroundcolor Red

}

 

Script to show all list of a Web

$spWeb = Get-SPWeb <Absolute Web Url>
$lists = $spweb.lists
foreach ($list in $lists)
{
 write-host "$List"
}



© Willi Neuner 2019 Impressum