How to Delete a SharePoint List using PowerShell?

Problem: A faulty solution installed on the SharePoint farm created duplicate lists in all sites in a large site collection with 100+ sites in it. We had to remove them all!

To delete a list from SharePoint, from the browser, we can go to: View All Site Content >> Click on “Remove” link from the context menu of the list. Alternatively, You can get into List Settings >> click on “Delete this list” to remove a list in SharePoint.

delete list from sharepoint powershell

However, There are 100+ sites where a particular list needs to be deleted.

Delete SharePoint list using PowerShell

PowerShell command to delete list in SharePoint:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Site collection URL 
$ListName = "List-Name-To-Delete"

#Get Web and List objects
$web = Get-SPWeb $SiteURL
$list = $web.Lists[$ListName]

#Reset the "Allow Deletion" Flag
$list.AllowDeletion = $true


write-host "List has been deleted successfully!"

One liner to delete a SharePoint list using PowerShell:

Get-SPWeb "https://Your-Site-URL" | Where-Object { $_.Lists.Delete([System.Guid]$_.Lists["Your-List-Name"].ID) }

SharePoint PowerShell to Delete List by GUID

Get-SPWeb "https://your-SharePoint-Site-URL" | Where-Object { $_.Lists.Delete([System.Guid]"{43c30f3a-f39a-4410-976c-a87bebb36e42}") }

Just replace the Web URL and GUID with yours and run the script.

Lets make a custom function to delete SharePoint list using PowerShell script.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Custom function to delete SharePoint list or document library using powershell
Function Delete-SPList
        [string]$WebURL  = $(throw "Please Enter the Web URL!"),
        [string]$ListName = $(throw "Please Enter the List Name to Delete!")
    #Get the Objects 
    $Web = Get-SPWeb $WebURL
    $List = $Web.lists[$ListName]
        #Set Allow Delete Flag
        $list.AllowDeletion = $true

        #delete list from sharepoint using powershell - Send List to Recycle bin
        #TO permanently delete a list, Use: 

        Write-Host "List: $($ListName) deleted successfully from: $($WebURL)"
        Write-Host "List: $($ListName) doesn't exist at $($WebURL)"

#Call the function to delete list
Delete-SPList "" "ConfigListv1"

So, call the function by looping through sites:

#Site URL variable
$SiteURL ="" 

#get the site collection
$Site = Get-SPSite $SiteURL

#Loop through each site in the site collection
Foreach($web in $site.Allwebs)
    #Call the function to delete list
    Delete-SPList $web.URL "ConfigListv1"

Force delete corrupt SharePoint list using PowerShell:
In some cases, you need PowerShell’s help when you are unable to delete the list from SharePoint web UI as the list is corrupted and SharePoint won’t let you remove it, Use this script to remove the SharePoint list using PowerShell: Force delete corrupted list in SharePoint using PowerShell

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

2 thoughts on “How to Delete a SharePoint List using PowerShell?

Leave a Reply

Your email address will not be published. Required fields are marked *