Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

Check In All Documents in a SharePoint Library using PowerShell

$
0
0
Requirement: Check-in All files which are checked out in a SharePoint document library.

How to Check In all checked out documents in SharePoint 2013:
SharePoint 2013 makes it simpler by providing context sensitive ribbon buttons to check in multiple files in bulk. Simply select all files which are checked-out and click on "Check In" button from the ribbon.
check in multiple documents in SharePoint 2013
Butthis method doesn't work when you have any required field with no default value assigned!

Check In All Documents in a SharePoint Library using PowerShell
When you do Multiple file upload (bulk upload or through explorer view) and your required column doesn't has any default value in it, then your files will be checked-out automatically. The "Check In" button won't work when you miss-out any required fields in the library.
You must fill out all required properties before checking in this document.

So, our solution is: PowerShell.

PowerShell script to check in all documents in the library:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for Site URL and Library Name
$WebURL="http://sharepoint.crescent.com/sites/sales"
$LibraryName="Proposal Documents"

#Get Site and Library
$Web = Get-SPWeb $WebURL
$DocLib = $Web.Lists.TryGetList($LibraryName)

#Get all Checked out files
$CheckedOutFiles = $DocLib.Items | Where-Object { $_.File.CheckOutStatus -ne "None"}

#Check in All Checked out Files in the library
ForEach($item in $CheckedOutFiles)
{
#If you want to update fields
#$item["Field"] = "value"
#$item.SystemUpdate()

#check in file programmatically
#$item.TakeoverCheckout()
$DocLib.GetItemById($item.Id).file.CheckIn("Checked in by Admin")
write-host "File:'$($item.Name)' has been checked in!"
}

Its possible to check-in file without supplying required field values through PowerShell!

If you want to do this for all libraries in your entire SharePoint web application, use: Find All Checked Out Files and Check-In them Back

Viewing all articles
Browse latest Browse all 1058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>