I have a list urls for specific SharePoint 2010 pages. I can visit each page and click the publish button. Then approve button to publish the pages.
I am trying to automate the process. I am wondering if there is any way to do that 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");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With