Set default master page using powershell script

Set default master page using below powershell script



#Author: Prem Kumar
#Date: Feb 11 2015

 param(
[string]$rooturl = $(Read-Host -prompt "Enter Web Application Root URL...?")
)

try
{
    $web = Get-SPWeb $rooturl
    write-host "Setting master pages to $rooturl"
    $web.CustomMasterUrl = "/service/_catalogs/masterpage/CustomMaster.master"
    $web.MasterUrl ="/service/_catalogs/masterpage/CustomSystemMaster.master"
    write-host "System and custom master page are set"
    $web.Update()
}

catch 
{
    write-host "Exception in Set Master Page - $_.Exception.Message"
}
finally
{
    $web.Dispose()
    write-host "Exit of Master Page..."
}

Comments

Popular posts from this blog

How to copy SharePoint list workflow

Generate Auto number Field in SharePoint list

INFOPATH FORM HIDE/DISABLE FIELDS BASED ON SHAREPOINT GROUP MEMBERSHIP