Feb 02 2017 09:15 PM
Feb 03 2017 12:30 AM
Hi,
Check the below script. To check files for "Manage files that have no checked in version", you need to use the condition :
$file.MajorVersion -eq "1" -and $file.Level -eq "Checkout"
This script uses SPO PnP also.
$cred=Get-Credential $UName=$cred.UserName.ToString() $Pass =$cred.GetNetworkCredential().Password $SiteURL = "https:// tenantname.sharepoint.com/sites/testsite2" $DocLibName = "Documents" connect-pnponline -Url $SiteURL -Credentials $cred $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") $Password = $Pass | ConvertTo-SecureString -AsPlainText -Force #Bind to site collection $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UName,$Password) $Context.Credentials = $Creds #Retrieve list $List = $Context.Web.Lists.GetByTitle($DocLibName) $Context.Load($List) $Context.ExecuteQuery() $Allfiles= $List.RootFolder.Files $Context.Load($Allfiles) $Context.ExecuteQuery() foreach( $file in $Allfiles){ If($file.MajorVersion -eq "1" -and $file.Level -eq "Checkout") { Set-PnPFileCheckedIn -Url $file.ServerRelativeUrl Write-Host $file.Name "Checked-in " } }
Feb 03 2017 03:01 AM - edited Feb 03 2017 03:24 AM
Feb 03 2017 03:01 AM - edited Feb 03 2017 03:24 AM
@NarasimaPerumal Chandramohan Thanks for the attempt, however it doesn't work. It doesn't show ANY files although I can see files in the UI. These files are uploaded by someone else besides me, but never fully checked-in in the first place. There is no 'version'. So $file.MajorVersion -eq "1" -and $file.Level -eq "Checkout" isn't a valid condition. Please see screenshots below.
1) Need to find where these files are located, and be able to load them up into the context
2) I need to take over the ownership with a similar method to on-premises SPCheckedOutFile.TakeOverCheckOut method. But that method doesn't exists because SPCheckedOutFile class doesn't exist in CSOM as far as I can see
Feb 03 2017 04:17 AM
Hi,
Please download the below codeplex project[SharePoint Online Client Browser] and check the properties of the files that you are refering and then you change the script accordingly.
Feb 03 2017 04:19 AM - edited Feb 03 2017 04:24 AM
Feb 03 2017 04:19 AM - edited Feb 03 2017 04:24 AM
I already used the SPCB. It doesn't see the files anywhere. ItemCount is reporting 4 there as well. But no files in sight.
Feb 03 2017 04:25 AM - edited Feb 03 2017 04:31 AM
Feb 03 2017 04:25 AM - edited Feb 03 2017 04:31 AM
@NarasimaPerumal Chandramohan I already used SharePoint Online Client Browser, and there are no files to be found. ItemCount shows 4 there as well, but Item are 0.
Feb 03 2017 04:36 AM
Can you check "Root Folder" under "Status Reports"?
Feb 03 2017 04:38 AM
@NarasimaPerumal Chandramohan I did. Here is the screenshot.