Tuesday, April 2, 2013

PowerShell - Change Master Page

I had to write a quick PowerShell script to change the Master Page for a SharePoint 2013 site. Thought to share it with the world.



$SiteUrl = "http://mySite1919/sites/MasterTest";
$NewMasterPage = "/_catalogs/masterpage/MasterPage_custom.master";

$SiteWeb = $Site.openweb();
$SiteRelativeUrl = $Site.ServerRelativeUrl.TrimEnd('/');

Write-Host "Site: " $SiteUrl;
Write-Host "Current MasterPage: " $SiteWeb.CustomMasterUrl;

#Site Master Page
$SiteWeb.CustomMasterUrl = $SiteRelativeUrl + $NewMasterPage;
#System Master Page
$SiteWeb.MasterUrl = $SiteRelativeUrl + $NewMasterPage;


Write-Host "New MasterPage: " $SiteWeb.CustomMasterUrl


Publiahing Sites vs Communication Sites

It was announced in SharePoint Virtual Summit in May 2017, a more modern way of content publishing is released called Communication Sites. ...