In SharePoint Online, lists store important data, but sometimes you may need to delete a list if it is no longer required. PnP PowerShell provides a simple way to delete a SharePoint list.
This guide covers:
How to connect to SharePoint Online
How to delete a SharePoint list
How to force delete without confirmation
How to restore a deleted list (if needed)
Prerequisites
Before deleting a list, ensure:
You have SharePoint Admin or Site Owner permissions.
You have PnP PowerShell installed.
You know the SharePoint site URL where the list exists.
Step 1: Install and Import PnP PowerShell
If you haven’t installed PnP PowerShell, install it using:
Install-Module -Name PnP.PowerShell -Scope CurrentUser -AllowClobber -Force
Then, import the module:
Import-Module PnP.PowerShell
PnP PowerShell is ready!
Step 2: Connect to SharePoint Online
To delete a list, first connect to the SharePoint site:
# Connect to SharePoint Online
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive
🔹 Replace "yourtenant"
with your tenant name.
🔹 Replace "yoursite"
with the site name where the list exists.
For app-based authentication, use:
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -ClientId "Your-App-Client-ID" -Tenant "yourtenant.onmicrosoft.com" -CertificatePath "Path\To\Certificate.pfx"
Connected successfully!
Step 3: Check Available Lists (Optional)
Before deleting, verify if the list exists:
# Get all lists in the site
Get-PnPList | Select Title, Id
This lists all SharePoint lists and their IDs.
Step 4: Delete a SharePoint List
Method 1: Delete a List with Confirmation
# Delete a SharePoint list
Remove-PnPList -Identity "Employee Directory" -Confirm
🔹 This will prompt a confirmation before deletion.
🔹 Replace "Employee Directory"
with your list name.
Method 2: Force Delete Without Confirmation
To delete a list without confirmation, use -Force
:
# Force delete a SharePoint list without confirmation
Remove-PnPList -Identity "Employee Directory" -Force
The list is deleted permanently!
Step 5: Verify Deletion
After deletion, verify the list no longer exists:
# Check if the list is deleted
Get-PnPList -Identity "Employee Directory"
If the list is deleted, this will return an error saying the list does not exist.
Step 6: Restore a Deleted List (If Needed)
If you accidentally deleted a list, restore it from the Recycle Bin:
# Restore a deleted SharePoint list
Restore-PnPRecycleBinItem -FirstStage -All
To restore only a specific list, first find its ID:
# Get all deleted items in Recycle Bin
Get-PnPRecycleBinItem | Select Title, Id
Then, restore it using its ID:
# Restore specific list using ID
Restore-PnPRecycleBinItem -Identity "<List-ID>"
The list is restored successfully!
Common Errors & Troubleshooting
Error | Cause | Solution |
---|---|---|
Remove-PnPList : Access Denied | You don’t have Site Owner/Admin permissions | Ensure you are a Site Owner or SharePoint Admin |
The term 'Remove-PnPList' is not recognized | PnP PowerShell is not installed | Run Import-Module PnP.PowerShell |
Cannot find list with identity 'Employee Directory' | The list does not exist | Check the list name using Get-PnPList before deleting |