Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE.eu :: Remove List Items CSOM SharePoint Online
Today, we will show you how to remove all items of the list using Client Object Model with PowerShell script for Office 365 sites. When you have more items to delete, we can go for batch delete. I would like to highlight programmatically when we delete list items, those are not moved to the Recycle Bin for the site.
First, Please find the below code. Hope this will help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
cls Add-Type-Path"E:\PSDLL\Microsoft.SharePoint.Client.dll" Add-Type-Path"E:\PSDLL\Microsoft.SharePoint.Client.Runtime.dll" $0=$MyInvocation.MyCommand.Definition $dp0=[System.IO.Path]::GetDirectoryName($0) $url="https://test.sharepoint.com/sites/test/" $username="abc@microsofttest.com" $password="*****" $securePassword=ConvertTo-SecureString$password-AsPlainText-Force #connect/authenticate to sharepoint online and get ClientContext object... $clientContext=New-ObjectMicrosoft.SharePoint.Client.ClientContext($url) $credentials=New-ObjectMicrosoft.SharePoint.Client.SharePointOnlineCredentials($username,$securePassword) $clientContext.Credentials=$credentials if(!$clientContext.ServerObjectIsNull.Value) { $web=$clientContext.Site.RootWeb $clientContext.Load($web) $clientContext.ExecuteQuery() $list=$clientContext.Web.Lists.GetByTitle('TestList') $clientContext.Load($list) $clientContext.ExecuteQuery() $query=New-ObjectMicrosoft.SharePoint.Client.CamlQuery $query.ViewXml="<View><RowLimit>1000</RowLimit></View>" $items=$list.GetItems($query) $clientContext.Load($items) $clientContext.ExecuteQuery() if ($items.Count-gt0) { for ($i=$items.Count-1; $i-ge0; $i--) { $items[$i].DeleteObject() } $clientContext.ExecuteQuery() } } |
SharePoint 2013 Hosting Recommendation
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options.
Print article | This entry was posted by Peter on July 26, 2016 at 5:33 am, and is filed under European SharePoint 2010 Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |