December 6, 2016

// // Leave a Comment

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..."
}

0 comments:

Post a Comment