如何从powershell发布/批准SharePoint 2010中的页面

如何从powershell发布/批准SharePoint 2010中的页面,sharepoint,powershell,sharepoint-2010,Sharepoint,Powershell,Sharepoint 2010,我有一个特定SharePoint 2010页面的URL列表。我可以访问每个页面并单击“发布”按钮。然后单击“批准”按钮发布页面 我正试图使这个过程自动化。我想知道是否有任何方法可以从powershell中执行此操作?下面的脚本应该可以执行此操作: $web = Get-SPWeb http://demo2010a:20905 $pages = "http://demo2010a:20905/Pages/TvAndRadioAlerts.aspx","http://demo2010a:20905/

我有一个特定SharePoint 2010页面的URL列表。我可以访问每个页面并单击“发布”按钮。然后单击“批准”按钮发布页面


我正试图使这个过程自动化。我想知道是否有任何方法可以从powershell中执行此操作?

下面的脚本应该可以执行此操作:

$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");
    }
}

你从什么着手来解决这个问题?您使用的是哪种类型的网站?