2
我希望能夠在頁面庫中創建頁面(並檢查它是否已存在)。如何使用PowerShell在給定的SharePoint 2010頁面庫中創建頁面
我還需要能夠將自定義頁面佈局應用於它,然後將其設置爲給定網站的主頁(如您在功能區中所示)。
我需要用PowerShell完成這三個步驟(我正在編寫一個部署腳本)。
感謝, 丹尼爾
我希望能夠在頁面庫中創建頁面(並檢查它是否已存在)。如何使用PowerShell在給定的SharePoint 2010頁面庫中創建頁面
我還需要能夠將自定義頁面佈局應用於它,然後將其設置爲給定網站的主頁(如您在功能區中所示)。
我需要用PowerShell完成這三個步驟(我正在編寫一個部署腳本)。
感謝, 丹尼爾
讓您發佈網這樣的:
$SPWeb = Get-SPWeb $websiteUrl -AssignmentCollection $spAssignment
$pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($SPWeb)
得到的頁面列表:
$pages = $pweb.GetPublishingPages($pweb)
get a page layout:
$ctype = $psite.ContentTypes["Your Page Layout Content Type"]
$pageLayouts = $psite.GetPageLayouts($ctype, $true)
$pageLayouts | ForEach-Object {
if ($_.Title -eq "Your Page Layout Title")
{
$layout = $_;
}
}
外觀爲您的網頁這樣
$pages | ForEach-Object {
if($_.Name -eq "default.aspx")
{
$page = $_;
}
}
更新佈局這種方式
if ($page -ne $null)
{
$page.CheckOut()
$page.Layout = $layout;
$page.Update();
}
如果需要
$item = $page.ListItem
if ($pg.PageContent -ne "")
{
$item["Title"] = "Your Title";
$item["Page Content"] = "Your content";
$item.Update()
}
支票&網頁發佈這樣
$page = $pages.Add("new.aspx", $layout)
$page.Title = "New Title";
$page.Update();
更新創建基於佈局的頁面等領域。
if ($page -ne $null)
{
$item.File.CheckIn("")
$item.File.Publish("")
$item.File.Approve("")
}