Updating Master Pages across SharePoint Site Collections Updating Master Pages across SharePoint Site Collections
Jaydeep Patel

Jaydeep Patel

December 24, 2013

All Post
img
Share:

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()
}

Leave a Reply

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

Want to talk?

Drop us a line. We are here to answer your questions 24*7.