更改所有站点的母版页

Change master page for all sites

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

感谢您的帮助

这应该有效。这将添加到您的母版页的所有 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()