Using Power Shell We can easily change our custom master page in our SharePoint site,once we prepare the script we can use for every time to change the master page.
"Get-SPWeb" i used to get the site URL of the SharePoint in a variable.
We have two Properties to control the master Page settings, CustomMasterUrl and MasterUrl
"Get-SPWeb" i used to get the site URL of the SharePoint in a variable.
We have two Properties to control the master Page settings, CustomMasterUrl and MasterUrl
Site Master Page
--- CustomMasterUrl
System Master Page
--- MasterUrl
Example:
$web = Get-SPWeb http://Dotnetsharepoint.com
$web.CustomMasterUrl =
"/_catalogs/masterpage/Custom.master"
$web.MasterUrl =
"/_catalogs/masterpage/Custom.master"
$web.Update()
If we have a site collection under a managed path like
"sites”, we can change using
“/sites/SITECOLLECTION/_catalogs/masterpage/Custom.master"
$web.CustomMasterUrl =
"/sites/DotnetSharePoint/_catalogs/masterpage/Custom.master"
$web.MasterUrl =
"/sites/DotnetSharePoint/_catalogs/masterpage/Custom.master