How to publish/approve a page in SharePoint 2010 from powershell How to publish/approve a page in SharePoint 2010 from powershell powershell powershell

How to publish/approve a page in SharePoint 2010 from powershell


The script bellow should do it:

$web = Get-SPWeb http://demo2010a:20905$pages = "http://demo2010a:20905/Pages/TvAndRadioAlerts.aspx","http://demo2010a:20905/Pages/Systems.aspx"$pages | ForEach-Object {$item = $web.GetListItem($_)    if ($item.File.CheckOutType -ne "None")    {        $item.File.CheckIn("Automatically checked in by Powershell", "MajorCheckIn");    }    if ($item.Versions[0].Level -ne "Published")    {        $item.File.Publish("Automatically published by Powershell");    }    if ($item.ModerationInformation.Status -ne "Approved")    {        $item.File.Approve("Automatically approved by by Powershell");    }}