Force UndoCheckout or checkin using PowerShell in SharePoint 2013

In this post, we will discuss how we can forcefully UndoCheckOut a page using PowerShell in SharePoint 2013. Sometimes when you will try using a browser you will not be able to UndoCheckout a page. In that case, PowerShell will be very much helpful.

You can read:
– The dictionary actions example in SharePoint Designer 2013

– SharePoint 2013 Calculate business day from InfoPath date picker or Get Day from the selected date in Date picker in InfoPath 2013

Get All Attachments From SharePoint 2013 List Item using Rest API

Below is the PowerShell command to UndoCheckOut default.aspx page from Pages document library.

Add-PSSnapin “Microsoft.SharePoint.PowerShell”
$targetWeb = “https://SiteURL”
$targetLibrary = “Pages”
$fileName = “default.aspx”

$myWeb = Get-SPWeb $targetWeb
$myLib = $myWeb.GetFolder($targetLibrary)
$myFile = $myLib.Files | ? {$_.name -eq $fileName}

$myFile.UndoCheckOut()

$myFile.Update()

Also you can use the below PowerShell command:
$web = Get-SPWeb https://SiteURL
$list = $web.Lists[“Pages”]
$file = $list.GetItemById(1); // ID of the file with the issue
$file.File.UndoCheckout()
$file.File.Checkin(“”)


You can check the item id from the Pages document library from the document library.

Hope this will be helpful.


You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →