SharePoint Online – Step by Step guide – PnP PowerShell to delete all items from the list

Hi All,

Greetings.

Today, starting new section – Step by Step guides.

Today first article in this series – How to remove all items from SharePoint Online list using PowerShell. – Small but very useful and handy

Detailed Steps:

$ClientID = "my client id"
PS C:\> $SiteURL = "my SharePoint site url"
PS C:\> Connect-PnPOnline -Url $SiteURL -Interactive -WarningAction Ignore -ClientId $ClientID -Force

  • Once we connected successfully, get all list items and remove one by one

#specify the list name
$ListName = "Demo List"
#fetch all the list items
$ListItems = Get-PnPListItem -List $ListName
#travel all list items and remove one by one
ForEach ($Item in $ListItems) {
Remove-PnPListItem -List $ListName -Identity $Item.Id -Force
}

References

Prasham Sabadra

LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.