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 "https://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("https://sharepoint.crescent.com")

Here is the One Liner:

Get-SPWebApplication "https://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 - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

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