SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a SharePoint (MOSS 2007) environment how can I list all the Master Pages (templates) that are used in a site collection? I need to add some code to the header of every master page, but there are a lot of subsites and I don't want to have to go to each subsite and check which master page it is using.

share|improve this question
up vote 0 down vote accepted

The master pages available in the Master pages and page layouts gallery at the root site of the site collection are available to all its sub sites. So you need update all the matser pages in there with the required headers.

Once this is done, changes would automatically reflect on all sub sites in that site collection using those master pages.

note: the master pages must be checked-in are approved after the updates

share|improve this answer
There are a lot of legacy Master pages there that are not used, I need to be able to tell which are actually in use. – DrStalker Oct 1 '10 at 6:33
Well there is no straight forward route to find the active master pages from top to bottom in a site collection. You would need to write a console application that can iterate recursively across the site collection and print the values of SPWeb.MasterUrl and SPWeb.CustomMasterUrl property. – Vivek Oct 1 '10 at 7:11
The comment is the accepted answer, not the accepted answer. If that makes sense. :-) – DrStalker Oct 5 '10 at 22:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.