Introduction
In this blog we will about check-in all checked out page in SharePoint 2013 using PowerShell method. We need to check-in many pages in our Site Collection for our development purpose.
For that I have created a small PowerShell script to work on this.
Steps
- Start your windows PowerShell on your computer.
- Right click and select Run as administrator option.
- Paste the below script on the PowerShell window and click the enter button.
- Check your SharePoint site page will be created successfully.
Code
- # Add the PowerShell Snapin
- $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
- if ($snapin -eq $null)
- {
- Add-PSSnapin "Microsoft.SharePoint.Powershell"
- }
- # Get the siteURL
- $spWeb = Get-SPWeb http:
- # Enter the pages library name
- $listName = "text"
- $list = $spWeb.Lists |? {$_.Title -eq $listName}
- foreach ($item in $list.Items)
- {
- $itemFile = $item.File
- # identify the all checked out file and do chekin using admin previlage
- if( $itemFile.CheckOutStatus -ne "None" )
- {
- $itemFile.CheckIn("Automatic CheckIn. (Administrator)")
- }
- }
- $spWeb.Dispose()
Run the script with the required administrator privilege.
To verify that, go the Pages Library and make sure that all pages are checked in.