using powershell to change the some sub-webs' system master page

Start-SPAssignment -Global
$SiteUrl = "your site url"
$NewSystemMasterPageUrl = "/CorporateCommunications/_catalogs/masterpage/v4.master"
$site = Get-SPSite $SiteUrl
$topWeb = Get-SPWeb $site.Url

foreach ($web in $topWeb.Webs)
{
    #Write-host $web.Title $web.MasterUrl
    $web.MasterUrl = $NewSystemMasterPageUrl;
    $web.AllProperties["__InheritsMasterUrl"] = "False"
    $web.Update();
}

Stop-SPAssignment -Global

 

Note: Start-SPAssignment here is used for the varialbes disposal purpose

 

posted @ 2013-01-26 15:44  举重-若轻  阅读(138)  评论(0编辑  收藏  举报