I am trying to set a custom master page on SP 2013 team site (on-prem). All the samples I can find involves the publishing feature, so I am turning here for tips on how set custom master page for a team site using powershell.



Firstly I agree with @Aveenav that you should look into the building wsp package, that will follow Sharepoint model, it will place the master page in layouts directory, push it if you connect servers etc. But if you really need to, you can place in the SP library, and call it from there (you can place in the layouts as well but you will have to keep that folder in sync when applying changes across directories, performance here is the key as /layouts is available faster) then set up the master page using this script:

$web = Get-SPWeb siteurl
$web.MasterUrl = "masterpagerelativeurl"

You have more examples at http://get-spscripts.com/2010/09/changing-master-page-on-sharepoint.html


Try appending URL

  • I tried, but didn't wokr
    – Ilyas
    May 3 '16 at 10:08
  • What you mean by not worked? Can you put the URL you have tired? May 3 '16 at 10:09
  • The url doesn't work on a team site. It gives an error. Have you tried it yourself ? I am looking for a way to do it with powershell also, on a team site.
    – Ilyas
    May 3 '16 at 10:12
  • Did you check in designer?
    – Anand
    May 3 '16 at 10:29
  • I think this will work only with publishing features on. Nov 20 '17 at 10:36

Instead of using PowerShell, create a WSP package and hookup and event receiver for the feature that sets the master page. That way you can apply same master page to sub sites.



{your site}/_layouts/15/ChangeSiteMasterPage.aspx

Amal's answer didn't have the 15 in it. I don't have enough rep to add a comment to his solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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