2016-01-24 32 views
-1

我有一個新的主人必須應用在我的所有網站上。 但我不知道通過Powershell來更改我的odler master頁面在數據庫(對於所有站點)中的內容。我知道如何迭代我的網站並修改母版頁的網址,但我只想更改母版頁的內容。更改所有網站的母版頁

感謝您的幫助

+0

爲什麼不使用SharePoint設計器。使用設計師可以更改主頁面的代碼。但支票是你應該擁有整個網站的最高網站特權。 – Siva

回答

0

這應該工作。這增加了所有Farm的主頁面。

foreach($webApp in (Get-SPWebApplication)) 
    foreach($site in $webApp.Sites) 

    # check compatibility level -> 14 if SP2010, 15 if SP2013 
    if ($site.CompatibilityLevel –eq 15) 
    foreach ($web in $site.AllWebs) 
     if ($web.Exists) 
     $web.SiteLogoUrl = "/SiteAssets/logo.png" 
     $web.SiteLogoDescription = "My PowerShell Site" 
     $web.MasterUrl = "/_catalogs/masterpages/seattle.master" 
     $web.CustomMasterUrl = "/_catalogs/masterpages/seattle.master" 

$web.Update() 

$web.Dispose() 
$site.Dispose() 
+0

你好!是的,我知道如何使用Sharepoint Designer,但我的目標是使用Powershell;'( – TWEESTY

+0

Hello Storm。你什麼時候上傳主內容的新內容?這是問題。在你的代碼中,你指向一個新的鏈接訪問新的母版頁,但你如何把這個母版頁放在這個鏈接的所有網站? – TWEESTY

+0

我寧願你google一下,你會發現噸的答案,例如http://sharepoint.stackexchange。 com/questions/17624/upload-master-page-using-powershell – STORM