Customized Master Pages Report for All SharePoint Sites

Today, wanted to audit customized Master pages which are deviating from our corporate Branding in my Team Sites environment.

Generated the report for customized master pages with help of PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get all site collections of provided web app
$SiteCollections = Get-SPWebApplication "http://sharepoint.crescent.com" | Get-SPSite -Limit All

#Loop through all site collections
foreach($Site in $SiteCollections)
{
	#Loop throuh all Sub Sites
	foreach($Web in $Site.AllWebs)
	{    
		#Get the Master Page
		$MasterPage = $Web.GetFile($Web.URL+"/"+$Web.MasterUrl)
	  
		#Check the Customization Status
		if($MasterPage.CustomizedPageStatus -eq "Customized")
		{
		   $MasterPage.Name  +" : " +$Web.Url  
		}
   }
}

If you want to use it in MOSS 2007, use these two lines of code to get a specific web application:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$webApp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup("http://sharepoint.crescent.com")

Here is the One Liner:

Get-SPWebApplication "http://sharepoint.crescent.com" | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, MasterUrl

Frankly, SharePoint Designer is a tool inducing people to get their site’s look and feel just as they want. I blame you SharePoint Designer for that. I’ve no options left other than locking you down from ordinary users.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply