{"id":50,"date":"2012-11-28T21:27:38","date_gmt":"2012-11-28T21:27:38","guid":{"rendered":"https:\/\/www.sharepoint13.org\/?p=50"},"modified":"2012-11-28T22:09:37","modified_gmt":"2012-11-28T22:09:37","slug":"ps-change-master-page-for-all-sites","status":"publish","type":"post","link":"https:\/\/www.sharepoint13.org\/?p=50","title":{"rendered":"PS Change Master Page for all sites +"},"content":{"rendered":"<p>Today I will share with you some nice PS snippets to change Master Page for all sites in the site collection. And if your read the entire post you can save a lot of time, not to mention the time used by the Branders to manually publish their CSS and master page. (ooooops, suddenly I have the entire SP Branding industry on my back \ud83d\ude42 )<\/p>\n<p>Let`s go:    <br \/>This first PS script will work on publishing sites, and non publishing sites. If you have a custom master page, just replace V4.master with your custom name.<\/p>\n<p><strong>$site = Get-SPSite http:\/\/intranet      <br \/>foreach ($web in $site.AllWebs) {       <br \/>$web; $web.CustomMasterUrl = &quot;\/_catalogs\/masterpage\/V4.master&quot;;&#160; <br \/>$web.Update(); $web.CustomMasterUrl;       <br \/>$web.Dispose()       <br \/>}       <br \/>foreach ($web in $site.AllWebs) {       <br \/>$web; $web.MasterUrl = &quot;\/_catalogs\/masterpage\/v4.master&quot;;&#160; <br \/>$web.Update(); $web.MasterUrl;       <br \/>$web.Dispose()       <br \/>}       <br \/>$site.Dispose()       <br \/>write-host &quot;May the force the with you! V4 Masterpage is now applied\u2026&quot;;<\/strong> <\/p>\n<p>\u2026 Nice\u2026 \ud83d\ude42    <br \/>-&gt;If you are even more lazy then me (if possible..) than feel free to copy with pride the following snippets to set alternate CSS on the top site:<\/p>\n<p><strong>$web = Get-SPWeb http:\/\/intranet      <br \/>$web.AlternateCssUrl = &quot;\/Style Library\/MyStyles\/main.css&quot;       <br \/>$web.AllProperties[&quot;__InheritsAlternateCssUrl&quot;] = $True       <br \/>$web.Update()<\/strong> <\/p>\n<p>Publishing sub sites will inherit\u2026 sweet\u2026.    <br \/>The next&#160; trick might come in handy if you are a foreigner, as in from Europe or Norway (like me), this snippet will set locale regional web settings to Norwegian Bokmaal:<\/p>\n<p><strong>$site = Get-SPSite http:\/\/intranet      <br \/>foreach ($web in $site.AllWebs) {       <br \/>$web; $web.Locale = 1044;&#160; <br \/>$web.Update(); $web.Locale;       <br \/>$web.Dispose()       <br \/>}       <br \/>$site.Dispose()<\/strong> <\/p>\n<p>And finally, why not associate the one logo to all sites in the site collection. (Hurraaii sais the CMO)<\/p>\n<p><strong>(get-spsite http:\/\/intranet).AllWebs | foreach {      <br \/>$_.SiteLogoUrl = &quot;\/style library\/Images\/R2D2.png&quot;;<\/strong> <\/p>\n<p>&#160; <br \/>This is a taste of Atea Rapid SharePoint\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I will share with you some nice PS snippets to change Master Page for all sites in the site collection. And if your read the entire post you can save a lot of time,<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[15,11,12,5],"class_list":["post-50","post","type-post","status-publish","format-standard","hentry","category-tip","tag-arsp","tag-powershell","tag-sharepoint-2010","tag-sharepoint-2013"],"_links":{"self":[{"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=\/wp\/v2\/posts\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=50"}],"version-history":[{"count":10,"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=\/wp\/v2\/posts\/50\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=\/wp\/v2\/posts\/50\/revisions\/60"}],"wp:attachment":[{"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sharepoint13.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}