更改所有站点的母版页

时间:2016-01-24 21:27:34

标签: powershell sharepoint sharepoint-2010 master-pages

我有一个新的主人,必须在我的所有网站上应用。 但我不知道通过Powershell更改我的odler母版页数据库(所有网站)的内容。我知道如何迭代我的网站并修改母版页的网址,但我只想更改母版页的内容。

感谢您的帮助

1 个答案:

答案 0 :(得分: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()