Delete rows from a SharePoint list through Powershell script

Another simple article, which provides a PowerShell script that I need to use to download a file from a Sharepoint site.

So for that we are using the Pnp.Powershell module by giving the Sharepoint online credentials and then we use Connect-PnPOnline function to connect in the account from the PowerShell.

The documentation of this module can be found here: PnP PowerShell Overview | Microsoft Docs
The documentation of this function can be found here: Connect-PnPOnline (PnP.Powershell) | Microsoft Docs

In order to work, we need to set the list name from Sharepoint in the variable called $ListName.

After that we use a do function while the count of items from that list is greater than zero. While that logic is negative, it will delete the rows: $items[0].DeleteObject().

Script example

Again it’s a really simple Powershell solution, and the script of this article can be found on my GitHub reporitory: guimatheus92/DeleteRowsFromSharepointList (github.com)

I hope you enjoyed this simple solution!

This blog is part of SharePoint Week. For more great content, click here

Check out Guilherme’s website here

About the Author:

Brazilian, engineer and developer well versed in BI, SQL, Data Modelling, Analysis Services, ETL Process, Python, VBA, Power BI, etc. Passionate about technology, who uses agile pratices and decision-making processes data-driven. You can find me in my LinkedIn profile, from my website and also from my Medium profile.

Reference:

Matheus. G. (2021). Delete rows from a Sharepoint list through Powershell script. Available at: https://guimatheus92.medium.com/delete-rows-from-a-sharepoint-list-through-powershell-script-aee081cb9d24 [Accessed: 14th September 2021].

Share this on...

Rate this Post:

Share:

Topics:

SharePoint

Tags: