2014-02-21 29 views
9

我有一個列出特定SharePoint 2010頁面的URL。我可以訪問每個頁面並點擊發布按鈕。然後批准按鈕以發佈頁面。如何在PowerShell中發佈/批准SharePoint 2010中的頁面

我試圖自動化該過程。我想知道是否有任何方法可以從PowerShell中做到這一點?

+0

你開始用什麼來解決這個問題?你在使用什麼類型的網站? – beavel

回答

14

腳本波紋管應該這樣做:

$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"); 
    } 
} 
相關問題