How to recover from a malfunctioning SharePoint Master Page

Recover from a broken Master Page

Last night I had a bit of fun trying to fix a bad Master Page that prevented access to anything in a site collection via the browser. This Master Page had a reference to a SharePoint Feature that had since been retracted and removed. The solution was to use PowerShell to change the Master Page:

$Site = get-spsite “http ://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()
}
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 *