In this article, let us see, how to enable the “Item Scheduling” in SharePoint 2013 Using PowerShell.
Before diving into the PowerShell Script, let us see, how to do that manually. i.e., through interface.
Let us go to the “Pages” Library – Settings.
Now, select the checkbox.
As mentioned in the warning, the Minor version and Major version needs to be enabled. That we will take care by the PowerShell Itself.
With this information, let us see the Script.
$LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
$LogFile = ".EnableItemScheduling.Pages-$LogTime.rtf"
cls
##================================================================================================
## Description : This script is used to Enable the ItemScheduling on the Authoring Site and Sub Sites Pages Document Library
## Author : Sathish Nadarajan
## Date : 15-Dec-2014
##================================================================================================
$Host.UI.RawUI.WindowTitle = "-- Enable Item Scheduling --"
$StartDate = Get-Date
Write-Host -ForegroundColor White "------------------------------------"
Write-Host -ForegroundColor White "| Enable the Item Scheduling on Pages Document Library of Authoring Site Collection and its SubWebs |"
Write-Host -ForegroundColor White "| Started on: $StartDate |"
Write-Host -ForegroundColor White "------------------------------------"
#start-transcript $logfile
$ErrorActionPreference = "Stop"
######################### Add SharePoint PowerShell Snapin ###############################################
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PSSnapin Microsoft.SharePoint.Powershell
}
########################### End of Add SharePoint PowerShell Snapin ##################################
######################## Set Execution Path ################################################
$scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
Set-Location $scriptBase
function EnableItemScheduling([string] $siteCollectionURL)
{
$Site = Get-SPSite $siteCollectionURL
$Site | Get-SPWeb -limit all | ForEach-Object{
$web=Get-SPWeb $_.Url
Write-Host "Enabling the ItemScheduling on the Web :- " $web.Title
$List = $web.Lists["Pages"]
$List.EnableModeration = $true
$List.EnableMinorVersions = $true
$List.Update()
# To enable Scheduling in the list
[Microsoft.SharePoint.Publishing.PublishingWeb]::EnableScheduling($List)
# To disable Scheduling in the list
# [Microsoft.SharePoint.Publishing.PublishingWeb]::DisableScheduling($list)
}
}
$Author = "http://C4968397007/"
EnableItemScheduling $Author
Happy Coding.
Sathish Nadarajan.
Leave a comment