Updating Master Pages across SharePoint Site Collections

Updating Master Pages across SharePoint Site Collections in your farm

You can use PowerShell to change the Master Page across site collections and across webs:

$Site = get-spsite “ht tp://SharePoint/Sites/SpecificSite”
$webcount = $Site.AllWebs.Count
$webs=$Site.AllWebs
for ($i=0; $i -lt $webcount; $i++)
{
$web=$webs[$i]
$Master=$web.get_MasterUrl()
$Master=$Master.Replace("your-custom-master", "v4.master")
$web.set_Masterurl($Master)
$web.update()
$web.dispose()
}

Make sure the Publishing feature is activated first:

Enable-SPFeature -Identity PublishingWeb -url $web.url
$wa=get-spwebapplication ht tp://webApp
foreach ($Site in $wa.sites)
{
if ($site.url -like $MatchStr)
{
$webcount = $Site.AllWebs.Count
$webs=$Site.AllWebs
for ($i=0; $i -lt $webcount; $i++)
{
$web=$webs[$i]
$Master=$web.get_MasterUrl()
$Master=$Master.Replace("v4.master","my-custom.master")
$web.set_Masterurl($Master)
$web.update()
$web.dispose()
}
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *