Search This Blog

Tuesday, August 27, 2013

To Roll out the Custom SharePoint Master Page to all existing sites using Powershell


To Roll out the Custom SharePoint Master Page:

$site = Get-SPSite http://intranet
foreach ($web in $site.AllWebs) {
$web; $web.CustomMasterUrl = "/_catalogs/masterpage/MyCustom.master"; 
$web.Update(); $web.CustomMasterUrl;
$web.Dispose()
}
foreach ($web in $site.AllWebs) {
$web; $web.MasterUrl = "/_catalogs/masterpage/MyCustom.master"; 
$web.Update(); $web.MasterUrl;
$web.Dispose()
}
$site.Dispose()
/ C

Quick walkthrough: Create an file with the name ChangeMaster.ps1 with the script in this file. Log in to the SharePoint server and open SharePoint 2010 management shell. Type cd\ and hit enter. Type Get-SPSite http://NameOfYourIntranet | Get-SPWeb and verify that you can run powershell. If everthing went ok, you got an list of the sites in the collection, you can now just drag and drop the file onto the prompt.

No comments:

Post a Comment