We have 50,000+ has been checked out by users. We need to check-in back. Document library contain sub folders inside. Can anyone please powershell script for us.
Example: Document library name "Test lib", under that test1 folder, under that test2 folder, under that test3 folder likewise. on test8 or 9 folder checked-out file exist. We tried below script, no error and nothing coming. Just an seconds its coming completed. Seems something we are missing. Please suggest me.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0
Function CheckInAllDocs([string]$DoclibURL){
if ($docliburl.EndsWith("/")){
$docliburl = $docliburl.Substring(0,$docliburl.length-1)
}
$web = get-spweb -identity $docliburl.Substring(0,$docliburl.LastIndexOf("/"))
$doclib = $web.lists |where {$_.RootFolder.Name -eq $docliburl.Substring($docliburl.LastIndexOf("/")+1,$docliburl.length-$docliburl.LastIndexOf("/")-1)}
ForEach($item in $doclib.checkedoutfiles){
#$item.TakeoverCheckout()
$doclib.GetItemById($item.ListItemId).file.CheckIn("Checked in by Script")
write-host "$($item.LeafName) has been checked in"
}
}
#To use enter the location of a document library
CheckInAllDocs "http://server.com/apps/Files"