Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Powershell script to delete older versions of documents in a SharePoint online library

$
0
0

Sharath Aluri provided this script in a previous post, and it worked perfectly to disable versioning in a SharePoint online (365) library. Thanks so much to Sharath!

Does anyone have any ideas on how to enhance this script by deleting previous versions of all documents (except for the current version) in a given SharePoint online document library? This would likely require a foreach {} loop to loop through each item/file in the library, check its version number, then delete if that number is not equal to the current version.

Thanks!

#Set Parameter
$SiteURL="https://globalsp.sharepoint.com/sites/sharath/disable"
$ListName ="Documents"#Connect to the siteConnect-PnPOnline $SiteURL -UseWebLogin#-Credentials (Get-Credential)#Set versioning settings of the ListSet-PnPList-Identity $ListName -EnableVersioning $False


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>