Sunday, September 1, 2013

Change the SharePoint Master Pages for Publishing Site and Non-Publishing Sites?

 My default master (V4.master)page in SharePoint 2010


Nowchanging from V4 master page to custom master page using below command in power shell.

$site = Get-SPSite http://Site URL/
foreach ($web in $site.AllWebs) {
$web; $web.CustomMasterUrl = "/_catalogs/masterpage/custom.master"; 
$web.Update(); $web.CustomMasterUrl;
foreach ($web in $site.AllWebs) {
$web; $web.MasterUrl = "/_catalogs/masterpage/custom.master"; 
$web.Update(); $web.MasterUrl;
write-host "Complete! Custom.master is now applied";

After execute this command,the result will be like this...

Happy scripting...

No comments:

Post a Comment