How To Delete A File From SharePoint

Deleting a file from SharePoint involves a simple process that can be easily followed. To delete a file, there are a few steps you need to take. First, ensure that the file is not checked out to another user and that you have the appropriate permissions to delete it. If the file is part of a folder, make sure to delete any files within the folder that are subject to retention policies.

If the site has exceeded its storage limit, it is recommended to increase the site quota before attempting to delete the file. This will ensure that you have enough space to accommodate the deletion.

Administrators can also utilize PowerShell commands from SharePoint Patterns and Practices (PnP) to force the deletion of items that cannot be deleted otherwise. These commands can be especially useful for resolving any issues or restrictions encountered during the deletion process.

To delete a file from SharePoint, you can go to the document library in SharePoint, select the file, and click on the “Delete” button located in the toolbar. This straightforward approach allows for a quick and efficient deletion of the file.

Alternatively, you can utilize PowerShell scripts to delete files from SharePoint. Simply specify the site URL and the file’s relative URL or item ID in the script, and the file will be deleted accordingly.

It is important to note that when you delete a folder in SharePoint, all its files and subfolders will also be deleted. Therefore, exercise caution while deleting folders to avoid unintentional removal of important files.

Steps to Delete a File from SharePoint

To delete a file from SharePoint, follow these steps carefully:

  1. Access the document library where the file is located. This can typically be found within the SharePoint site.
  2. Select the file you wish to delete by clicking on it. This will highlight the file and open up the toolbar at the top of the page.
  3. In the toolbar, locate and click on the “Delete” button. This will prompt a confirmation message to ensure you want to proceed with the deletion.
  4. If you are certain you want to delete the file, click “OK” on the confirmation message. The file will then be permanently deleted from SharePoint.

Alternatively, you can use PowerShell scripts to delete files from SharePoint. This method is particularly useful for administrators or users with advanced technical knowledge. To delete a file using PowerShell, you will need to specify the site URL and the file’s relative URL or item ID. This allows for more flexibility and control when deleting files from SharePoint.

It’s important to note that when you delete a folder from SharePoint, all its files and subfolders will also be deleted. Therefore, be cautious when deleting folders to avoid any unintentional loss of data.

Example: PowerShell Script to Delete File

“Connect-PnPOnline -Url https://yoursharepointsite.com
Remove-PnPListItem -List ‘Documents’ -Identity 1″

The above example demonstrates a PowerShell script to delete a file with the item ID of 1 from the “Documents” list in SharePoint.

Step Description
1 Connect-PnPOnline -Url https://yoursharepointsite.com
2 Remove-PnPListItem -List ‘Documents’ -Identity 1

By following these steps, you can easily delete files from SharePoint using either the document library toolbar or PowerShell scripts, depending on your needs and level of technical expertise.

Considerations and Important Notes

Before deleting a file from SharePoint, there are a few important considerations to keep in mind.

Firstly, ensure that the file is not checked out to another user and that you have the appropriate permissions to delete it. This will prevent any conflicts or restrictions that may hinder the deletion process.

If the file is part of a folder, remember to delete any files within the folder that are subject to retention policies. This is crucial in maintaining compliance and data governance within your SharePoint environment.

Additionally, if the site has exceeded its storage limit, it is recommended to increase the site quota before attempting to delete the file. This will help avoid any interruptions or errors during the deletion process.

For administrators, PowerShell commands from SharePoint Patterns and Practices (PnP) can be utilized to force the deletion of items that cannot be deleted through regular means. These commands provide a powerful toolset for managing and handling complex deletion scenarios.

When deleting a file, you can navigate to the document library in SharePoint, select the file, and click on the “Delete” button in the toolbar. Alternatively, you can employ PowerShell scripts that specify the site URL and the file’s relative URL or item ID for more efficient deletion workflows.

Lastly, it’s crucial to note that deleting a folder will also delete all its files and subfolders. Therefore, exercise caution when deleting folders to avoid unintended consequences.

Meet the Author

Abdul Rahim has been working in Information Technology for over two decades. Learn how Abdul got his start as a Tech Blogger , and why he decided to start this Software blog. If you want to send Abdul a quick message, then visit his contact page here.