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 - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

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