Shantha Kumar T
Check in all checked-out files using Office 365 CLI
Office 365 CLI provides a limitless way to SharePoint and Office 365 data. There is a lot of examples are missing for Office 365 CLI command. So in this blog post, I am going to give an example for retrieving all checked out files in a folder and how to check-in all files in that folder.
Get the list of all checked out files:
The below script uses the CheckedoutUserId for filtering the checked-out files from the folder.
$libraryName = "Documents"; $weburl = "https://ktsdemo.sharepoint.com/dev"; o365 spo listitem list --title $libraryName --webUrl $weburl --filter "CheckoutUserId ne null" --fields "Title,FileLeafRef,FileRef" --output json | ConvertFrom-Json
To retrieve based on specific user checked out documents, –filter condition should be “CheckoutUserId eq
Check-In all checked out files:
The below script first retrives the list of all checkout files and then uses the spo file checkin command to checkin the file based on the fileurl property.
$libraryName = "Documents"; $weburl = "https://ktsdemo.sharepoint.com/dev"; $checkedoutfiles = o365 spo listitem list -t $libraryName -u $weburl --filter "CheckoutUserId ne null" --fields "Title,FileLeafRef,FileRef" --output json | ConvertFrom-Json $checkedoutfiles | ForEach-object { o365 spo file checkin -u $weburl --fileUrl $_.FileRef --type "Major"; }