We want to force check-in all the documents at "site collection level" i.e from all its sub-sites and all document library. Would need help on a powershell script which can do the same.
BR/ Somesh
We want to force check-in all the documents at "site collection level" i.e from all its sub-sites and all document library. Would need help on a powershell script which can do the same.
BR/ Somesh
The following PowerShell Script will check in all checked out files on the specified site collection. It iterates each web in the site collection, gets all lists of type DocumentLibrary (not hidden), gets all checked out files, and checks each one in.
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
$siteUrl = "http://yoursharepointsite"
$webs = (Get-SPSite -Identity $siteUrl).AllWebs
ForEach ($web in $webs) {
$libs = $web.GetListsOfType(1)
ForEach ($lib in $libs | ? { $_.Hidden -eq $false }) {
$files = $lib.CheckedOutFiles
ForEach ($file in $files) {
$f = $web.GetFile("/" + $file.Url)
$f.CheckIn("Checked in by System")
Write-Host -ForegroundColor Green "File: $($file.Url) checked in!"
}
}
}
Hope this helps!