I wrote a script that traverses a collection, it's document libraries and gets a list of all files. I'm trying to find all the documents which do not have a checked in version and require a user to go to settings > manage files with no checked in version.

I wrote this CAML Query in an attempt to return those files:

<FieldRef Name="_UIVersionString" />
<Value Type="Text">1.0</Value>
<FieldRef Name="CheckoutUser" />

However it doesn't work like intended unfortunately. Any ideas on how I could accomplish this?

  • does it return any results? I would think that the field value would need to be less than or equal to 1.0 <Leq> – Mike Dec 17 '13 at 19:43
  • What I have does return results. It returns just normal files who have been checked out and are at version 1 and it returns files which have never been checked-in and are at version 1. – Batman Dec 17 '13 at 21:27
  • Batman, I wonder whether you got answer to your question. I am also in the same situation, Please share your answer if you got one. Thanks – user24594 Mar 24 '14 at 11:19

How about:

         <FieldRef Name='_Level' />
         <Value Type='Integer'>255</Value>

Looking at a Pages library where I created a new item sitting at version .1, I see the _Level field at 255 and for checked in major versions it's 1.

Or maybe

<Where><And><Eq><FieldRef Name='_Level' /><Value Type='Integer'>255</Value></Eq><Eq><FieldRef Name='_UIVersionString' /><Value Type='Text'>.1</Value></Eq></And></Where>
  • So this is a normal file that's successfully been checked in right? I' trying to find the files that have never been checked in. – Batman Dec 18 '13 at 0:22
  • All I did was Documents, New Document. Gave it a title and a page layout and clicked Create, which is the bare minimum you can do. And going to the Manage checked out files link, I see the page sitting there. – Eric Alexander Dec 18 '13 at 0:31
  • oh okay. Well I'll give that a shot, see what happens. But I don't think it will work. The level 255 property will return all documents which are checked out. Whether they've ever been checked in or not. If there was a property like "CheckInDate" then I could do a search on null values but I don't think there's anything like that unfortunately. – Batman Dec 18 '13 at 0:39
  • Doesn't return anything unfortunately. – Batman Dec 18 '13 at 5:17

I have done similar using a PowerShell script. In my case I populated a list with the results which meant I could prompt users etc from there. PowerShell had to loop through each document library twice, first time getting files that had never been checked in and then to get the documents that had been checked in at some point but were now checked out.

The script is quite lengthy but happy to share the key parts if that would help - let me know.



    <FieldRef Name="_UIVersion" />
    <Value Type="Integer">512</Value>

Every major version is equivalent to 512 in UIVersion, so by finding items with a value of less (Le) than 512, you will get all items that has never been published.

  • Just tried this but I get the error: <errorstring xmlns="schemas.microsoft.com/sharepoint/soap/">Value does not fall within the expected range.</errorstring – Batman Dec 17 '13 at 21:37
  • I just checked using U2U CAML Query, documents which have no checked in version still have a value of 512. I'm trying to find something else that might distinguish them but I'm starting to think that's not possible using client-side code. – Batman Dec 17 '13 at 22:16
  • Strange :( If it is a draft it has less than 512, but I guess for that you need minor versioning enabled. – Robert Lindgren Dec 18 '13 at 7:01
  • Yea we don't usually have minor versioning enabled. – Batman Dec 18 '13 at 16:35
  • Also, I think I'm running in to the issue where it's looking through the list for the files but if the files are checked out to someone else, I don't see them in the list. I think need to find a more direct way to see the files in ManageCheckedOutFiles.aspx – Batman Dec 18 '13 at 16:42

I am not a expert in sharepoint but tried something that worked for me. So just giving a thought.


  1. Make sure the person should have either full control to the site or is a sitecollection administrator.
  2. Please note that this was the migration technique that we used to migrate the documents which have no checked in version because metalogix was not able to migrate those documents.

First Step: You can first write powershell script that opens the ie browser silently and manupulate the DOM of the page (Managed file which have no checked in version).


$ie = new-object -com internetexplorer.application

while($ie.busy) {
    sleep 1

#below code to select the elements to take control of the document (left hand side checkbox)
$jsCommand = @"
    function confirm(){
        return true;
    function alert(text){
$document = $ie.document
$window = $document.parentWindow
#executing the javascript by overiding the native function
$window.execScript($jsCommand, 'javascript') | Out-Null

#this is the code to click the "Take The Ownership" link
$link = $ie.Document.getElementById('ctl00_PlaceHolderMain_Toolbar_RptControls_ButtonRestoreItems_LinkText')
    Write-Host $_
    #do the dispose of the object

Second Step (Validation): After you ran this in powershell ISE, then please execute this below code to see if now you can get the manage files which has no checked in item count. If then you can retrive the item then the account can do checkin of the document without any issue.

$currentDir =$(Get-Location).Path
Add-Type –Path $currentDir"\ClientDLL\Microsoft.SharePoint.Client.dll"
Add-Type –Path $currentDir"\ClientDLL\Microsoft.SharePoint.Client.Runtime.dll"

$urlSite="sharepoint web url"
    $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($urlSite)
    #$clientContext.Credentials = New-Object System.Net.NetworkCredential("username with domain", "password")
    $list = $clientContext.Web.Lists.GetByTitle("document library name");
    $caml = "<View Scope='RecursiveAll'><Query><Where><IsNotNull><FieldRef Name='CheckoutUser' /></IsNotNull></Where></Query></View>"
    $cq= New-Object Microsoft.SharePoint.Client.CamlQuery
    $items = $list.GetItems($cq)
    echo $list.ItemCount
    echo $items.Count
    Write-Host $_

If you are using in ServerObject Model I can say that you can look for TakeOverCheckout method as pointed here but it is valid only for on-premise environment. Literally I have never tried it but maybe worth mentioning. Please look at the documentation below:


Best of luck!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.