Check in and Check out default page using PowerShell in SharePoint 2013/2016

This PowerShell SharePoint tutorial will discuss how to check in and check out the default page using PowerShell in SharePoint 2013/2016. Below example, we will see how to check out and check in the SharePoint page using PowerShell.

Check in and Check out default page using PowerShell in SharePoint 2013

Below is the PowerShell command which will checkout and check-in all the site’s default.aspx page and subsites under the SharePoint site collection. You can write the script in PowerShell ISE.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$SPsite = Get-SPSite "https://SiteURL"
foreach ($SPweb in $SPsite.AllWebs)
{
#$SPweb | Select-Object -Property Title,Url,WebTemplate
$SPFile = $SPWeb.GetFile("default.aspx");
$SPFile.CheckOut("Online",$null);
$SPFile.CheckIn(1);
$SPweb.Dispose()
}
$SPsite.Dispose()

Below is the PowerShell command which will check in or checkout page in a particular subsite (here in this example it will check in checkout the default.aspx page of Mysubsite subsite).

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$SPsite = Get-SPSite "https://SiteURL"
foreach ($SPweb in $SPsite.AllWebs)
{
if($SPweb.Url -eq "https://SiteURL/Mysubsite")
{
#$SPweb | Select-Object -Property Title,Url,WebTemplate
$SPFile = $SPWeb.GetFile("default.aspx");
$SPFile.CheckOut("Online",$null);
$SPFile.CheckIn(1);
$SPweb.Dispose()
}
}
$SPsite.Dispose()

You may like following SharePoint PowerShell tutorials:

This SharePoint tutorial we learned how to check-in and check out SharePoint page using PowerShell.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

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 SPGuides.com

>