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!

Mechanical Engineer Business Intelligence developer, passionate about technology, I have knowledge and experience to create a BI architecture and much more 📚.