Fixing Checked Out Files Fixing Checked Out Files
Alexis Daniel

Alexis Daniel

February 23, 2014

All Post
Fixing Checked Out Files
Share:

Fixing Checked Out Files

I ran into a challenge this evening with a monstrously large library filled with 5,000+ folders with 47,000+ files.

What to do?

Firstly, things don’t work correctly until the list view threshold is temporarily lifted. Once that is done, we can iterate through the files, take the checked out ones over, and force the check in.

Here’s how:

$root = get-spweb "ht tp://SharePoint/sites/site"
$lib = $root.lists["LibraryName"]
$x = $lib.CheckedOutFiles
$count = $x.Count
for ($i=$count-1; $i -ge 0; $i--)
{
$Checkeditem = $x.get_Item($i)
$Checkeditem.TakeOverCheckOut()
 
$libitem = $lib.GetItemById($Checkeditem.listitemid)
$libitem.File.CheckIn("")
Write-Host -NoNewline "."
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to talk?

Drop us a line. We are here to answer your questions 24*7.