{"id":962,"date":"2012-02-20T19:01:44","date_gmt":"2012-02-21T03:01:44","guid":{"rendered":"http:\/\/blog.brainlitter.com\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/"},"modified":"2012-02-20T19:01:44","modified_gmt":"2012-02-21T03:01:44","slug":"how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page","status":"publish","type":"post","link":"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/","title":{"rendered":"How to set all webs (sub sites as some call them) in a site collection, to use a common master page"},"content":{"rendered":"<p>In environments where the publishing features aren&#8217;t used (or desired), or available (such as SharePoint Foundation installs, being able to set all webs (Sub sites) in a site collection to a common Master Page using PowerShell is very useful. Here&#8217;s how\u2026 <\/p>\n<pre class=\"csharpcode\">$site = Get-SPSite http:<span class=\"rem\">\/\/portal.somewhere.com\/ <\/span>\n$sites = @(<span class=\"kwrd\">foreach<\/span> ($web <span class=\"kwrd\">in<\/span> $site.AllWebs) { \n$web | Select-Object -Property Url \nWrite-Debug <span class=\"str\">\"Setting master pages in web ($($web.Url))...\"<\/span> \n$web.MasterUrl = <span class=\"str\">\"\/_catalogs\/masterpage\/your_custom_page.master\"<\/span> \n$web.Update() \n$web.Dispose() \n}) | <span class=\"kwrd\">out<\/span>-File -filepath <span class=\"str\">\"c:masterpagesmodifiedOutput.txt\"<\/span> \n$site.Dispose() \n<\/pre>\n<p>&nbsp; <\/p>\n<p>The above will go through all the webs in the chosen site collection URL (in this case, <a href=\"http:\/\/portal.somewhere.com\">http:\/\/portal.somewhere.com<\/a>, but could easily be <a href=\"http:\/\/portal.somewhere.com\/sites\/HR\">http:\/\/portal.somewhere.com\/sites\/HR<\/a>) and set the master page to the desired master page and will produce a text file outlining which webs it found along the way. Items in bold black will need to be set to suit. <\/p>\n<h2>To Run It<\/h2>\n<ol>\n<li>Save the above after you have customized it as <strong>pushmasterpages.ps1<\/strong> (using notepad, or whatever\u2026) <\/li>\n<li>Open SharePoint 2010 Management Shell (Powershell) <\/li>\n<li>Launch Powershell against that file (assuming it is in the root of C:), that would be: <\/li>\n<\/ol>\n<pre class=\"csharpcode\">.pushmasterpages.ps1<\/pre>\n<pre class=\"csharpcode\">&nbsp;<\/pre>\n<pre class=\"csharpcode\">&nbsp;<\/pre>\n<p>.csharpcode, .csharpcode pre<br \/>\n{<br \/>\n\tfont-size: small;<br \/>\n\tcolor: black;<br \/>\n\tfont-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br \/>\n\tbackground-color: #ffffff;<br \/>\n\t\/*white-space: pre;*\/<br \/>\n}<br \/>\n.csharpcode pre { margin: 0em; }<br \/>\n.csharpcode .rem { color: #008000; }<br \/>\n.csharpcode .kwrd { color: #0000ff; }<br \/>\n.csharpcode .str { color: #006080; }<br \/>\n.csharpcode .op { color: #0000c0; }<br \/>\n.csharpcode .preproc { color: #cc6633; }<br \/>\n.csharpcode .asp { background-color: #ffff00; }<br \/>\n.csharpcode .html { color: #800000; }<br \/>\n.csharpcode .attr { color: #ff0000; }<br \/>\n.csharpcode .alt<br \/>\n{<br \/>\n\tbackground-color: #f4f4f4;<br \/>\n\twidth: 100%;<br \/>\n\tmargin: 0em;<br \/>\n}<br \/>\n.csharpcode .lnum { color: #606060; }<\/p>\n<p>.csharpcode, .csharpcode pre<br \/>\n{<br \/>\n\tfont-size: small;<br \/>\n\tcolor: black;<br \/>\n\tfont-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br \/>\n\tbackground-color: #ffffff;<br \/>\n\t\/*white-space: pre;*\/<br \/>\n}<br \/>\n.csharpcode pre { margin: 0em; }<br \/>\n.csharpcode .rem { color: #008000; }<br \/>\n.csharpcode .kwrd { color: #0000ff; }<br \/>\n.csharpcode .str { color: #006080; }<br \/>\n.csharpcode .op { color: #0000c0; }<br \/>\n.csharpcode .preproc { color: #cc6633; }<br \/>\n.csharpcode .asp { background-color: #ffff00; }<br \/>\n.csharpcode .html { color: #800000; }<br \/>\n.csharpcode .attr { color: #ff0000; }<br \/>\n.csharpcode .alt<br \/>\n{<br \/>\n\tbackground-color: #f4f4f4;<br \/>\n\twidth: 100%;<br \/>\n\tmargin: 0em;<br \/>\n}<br \/>\n.csharpcode .lnum { color: #606060; }<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In environments where the publishing features aren&#8217;t used (or desired), or available (such as SharePoint Foundation installs, being able to set all webs (Sub sites) in a site collection to a common Master Page using PowerShell is very useful. Here&#8217;s how\u2026 $site = Get-SPSite http:\/\/portal.somewhere.com\/ $sites = @(foreach ($web in $site.AllWebs) { $web | Select-Object &hellip; <a href=\"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/\"><\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[14,334,450],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to set all webs (sub sites as some call them) in a site collection, to use a common master page - Brainlitter - Inside the mind of Sean Wallbridge<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to set all webs (sub sites as some call them) in a site collection, to use a common master page - Brainlitter - Inside the mind of Sean Wallbridge\" \/>\n<meta property=\"og:description\" content=\"In environments where the publishing features aren&#8217;t used (or desired), or available (such as SharePoint Foundation installs, being able to set all webs (Sub sites) in a site collection to a common Master Page using PowerShell is very useful. Here&#8217;s how\u2026 $site = Get-SPSite http:\/\/portal.somewhere.com\/ $sites = @(foreach ($web in $site.AllWebs) { $web | Select-Object &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/\" \/>\n<meta property=\"og:site_name\" content=\"Brainlitter - Inside the mind of Sean Wallbridge\" \/>\n<meta property=\"article:published_time\" content=\"2012-02-21T03:01:44+00:00\" \/>\n<meta name=\"author\" content=\"Sean Wallbridge\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sean Wallbridge\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/\",\"url\":\"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/\",\"name\":\"How to set all webs (sub sites as some call them) in a site collection, to use a common master page - Brainlitter - Inside the mind of Sean Wallbridge\",\"isPartOf\":{\"@id\":\"https:\/\/regroove.ca\/brainlitter\/#website\"},\"datePublished\":\"2012-02-21T03:01:44+00:00\",\"dateModified\":\"2012-02-21T03:01:44+00:00\",\"author\":{\"@id\":\"https:\/\/regroove.ca\/brainlitter\/#\/schema\/person\/74e1c0def190f181c1394c2b6d883e77\"},\"breadcrumb\":{\"@id\":\"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Brainlitter\",\"item\":\"https:\/\/regroove.ca\/brainlitter\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to set all webs (sub sites as some call them) in a site collection, to use a common master page\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/regroove.ca\/brainlitter\/#website\",\"url\":\"https:\/\/regroove.ca\/brainlitter\/\",\"name\":\"Brainlitter - Inside the mind of Sean Wallbridge\",\"description\":\"Dad. Husband. Drummer. Learner of Things.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/regroove.ca\/brainlitter\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/regroove.ca\/brainlitter\/#\/schema\/person\/74e1c0def190f181c1394c2b6d883e77\",\"name\":\"Sean Wallbridge\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/regroove.ca\/brainlitter\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/adf8cea6291c39d166616f2148d919a6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/adf8cea6291c39d166616f2148d919a6?s=96&d=mm&r=g\",\"caption\":\"Sean Wallbridge\"},\"url\":\"https:\/\/regroove.ca\/brainlitter\/author\/swallbridge\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to set all webs (sub sites as some call them) in a site collection, to use a common master page - Brainlitter - Inside the mind of Sean Wallbridge","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/","og_locale":"en_US","og_type":"article","og_title":"How to set all webs (sub sites as some call them) in a site collection, to use a common master page - Brainlitter - Inside the mind of Sean Wallbridge","og_description":"In environments where the publishing features aren&#8217;t used (or desired), or available (such as SharePoint Foundation installs, being able to set all webs (Sub sites) in a site collection to a common Master Page using PowerShell is very useful. Here&#8217;s how\u2026 $site = Get-SPSite http:\/\/portal.somewhere.com\/ $sites = @(foreach ($web in $site.AllWebs) { $web | Select-Object &hellip;","og_url":"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/","og_site_name":"Brainlitter - Inside the mind of Sean Wallbridge","article_published_time":"2012-02-21T03:01:44+00:00","author":"Sean Wallbridge","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sean Wallbridge","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/","url":"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/","name":"How to set all webs (sub sites as some call them) in a site collection, to use a common master page - Brainlitter - Inside the mind of Sean Wallbridge","isPartOf":{"@id":"https:\/\/regroove.ca\/brainlitter\/#website"},"datePublished":"2012-02-21T03:01:44+00:00","dateModified":"2012-02-21T03:01:44+00:00","author":{"@id":"https:\/\/regroove.ca\/brainlitter\/#\/schema\/person\/74e1c0def190f181c1394c2b6d883e77"},"breadcrumb":{"@id":"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/regroove.ca\/brainlitter\/2012\/02\/20\/how-to-set-all-webs-sub-sites-as-some-call-them-in-a-site-collection-to-use-a-common-master-page\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Brainlitter","item":"https:\/\/regroove.ca\/brainlitter\/"},{"@type":"ListItem","position":2,"name":"How to set all webs (sub sites as some call them) in a site collection, to use a common master page"}]},{"@type":"WebSite","@id":"https:\/\/regroove.ca\/brainlitter\/#website","url":"https:\/\/regroove.ca\/brainlitter\/","name":"Brainlitter - Inside the mind of Sean Wallbridge","description":"Dad. Husband. Drummer. Learner of Things.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/regroove.ca\/brainlitter\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/regroove.ca\/brainlitter\/#\/schema\/person\/74e1c0def190f181c1394c2b6d883e77","name":"Sean Wallbridge","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/regroove.ca\/brainlitter\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/adf8cea6291c39d166616f2148d919a6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/adf8cea6291c39d166616f2148d919a6?s=96&d=mm&r=g","caption":"Sean Wallbridge"},"url":"https:\/\/regroove.ca\/brainlitter\/author\/swallbridge\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/posts\/962"}],"collection":[{"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/comments?post=962"}],"version-history":[{"count":0,"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/posts\/962\/revisions"}],"wp:attachment":[{"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/media?parent=962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/categories?post=962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regroove.ca\/brainlitter\/wp-json\/wp\/v2\/tags?post=962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}