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:
- Connect to SharePoint Online.
- We have quite good articles on – How to connect to Microsoft 365 with various different approaches
- Microsoft 365 : Detailed steps using Connect-PnPOnline with Client ID and X509 certificate
- PowerShell Modules / CMDLETs – Connecting to Microsoft 365 Services
- Microsoft 365 – Few approaches / options for Connecting to tenant using PnP PowerShell – Connect-PnPOnline – Part 1
- Microsoft 365 – Connecting to tenant using PnP PowerShell – Connect-PnPOnline – exploring DeviceLogIn (Device code flow) parameter- Part 2
- Ubuntu : Connecting SharePoint Online using PowerShell
- We have quite good articles on – How to connect to Microsoft 365 with various different approaches
$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
- Microsoft 365 : Detailed steps using Connect-PnPOnline with Client ID and X509 certificate
- PowerShell Modules / CMDLETs – Connecting to Microsoft 365 Services
- Microsoft 365 – Few approaches / options for Connecting to tenant using PnP PowerShell – Connect-PnPOnline – Part 1
- Microsoft 365 – Connecting to tenant using PnP PowerShell – Connect-PnPOnline – exploring DeviceLogIn (Device code flow) parameter- Part 2
- Ubuntu : Connecting SharePoint Online using PowerShell
