{"id":920,"date":"2016-04-02T19:29:36","date_gmt":"2016-04-02T19:29:36","guid":{"rendered":"https:\/\/regroove.ca\/stellark\/?p=920"},"modified":"2023-02-24T18:50:54","modified_gmt":"2023-02-24T18:50:54","slug":"turning-on-publishing-with-powershell-in-sharepoint-online","status":"publish","type":"post","link":"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/","title":{"rendered":"Turning on Publishing with PowerShell in SharePoint Online"},"content":{"rendered":"\n<p>We came across a situation recently where we needed to enable Publishing (at the web level \u2013 ie. It was already on at the site collection level) using PowerShell. This was in the context of a script that created many Sub Sites (webs) based on an automated process.<\/p>\n\n\n\n<p>A good time to remind everyone that using Sub Sites is generally bad practice these days with SharePoint. Site Collections are a far better idea. There are certain exceptions to that (such as the case that lead to the script in this blog post). Take a look at Sean Wallbridge&#8217;s post for more information <a href=\"https:\/\/regroove.ca\/brainlitter\/2015\/06\/01\/site-collections-for-the-win\/\">https:\/\/regroove.ca\/brainlitter\/2015\/06\/01\/site-collections-for-the-win\/<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> <br># LOAD SHAREPOINT SDK (whichever method you prefer)<br><br> $siteCollectionUrl = \"&lt;site collection URL here&gt;\"<br><br> $username = \"&lt;username here&gt;\"<br><br> # Prompt for password at runtime.<br><br> $password = Read-Host -Prompt \"Enter password\" -AsSecureString<br><br> $credentials = New-Object <br>Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)<br><br> $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteCollectionUrl)<br><br> $clientContext.Credentials = $credentials<br><br> $FeatureId = [GUID](\"94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb\")<br><br> $webFeatures = $clientContext.Web.Features<br><br> $clientContext.Load($webFeatures)<br><br> $clientContext.ExecuteQuery()<br><br> $webfeatures.Add($featureId, $force, <br>[Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)<br> $clientContext.ExecuteQuery() <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We came across a situation recently where we needed to enable Publishing (at the web level \u2013 ie. It was already on at the site collection level) using PowerShell. This was in the context of a script that created many Sub Sites (webs) based on an automated process. A good time to remind everyone that &hellip; <a href=\"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/\"><\/a><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[68,80],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Turning on Publishing with PowerShell in SharePoint Online - Stephanie Kahlam<\/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\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Turning on Publishing with PowerShell in SharePoint Online - Stephanie Kahlam\" \/>\n<meta property=\"og:description\" content=\"We came across a situation recently where we needed to enable Publishing (at the web level \u2013 ie. It was already on at the site collection level) using PowerShell. This was in the context of a script that created many Sub Sites (webs) based on an automated process. A good time to remind everyone that &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/\" \/>\n<meta property=\"og:site_name\" content=\"Stephanie Kahlam\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-02T19:29:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-24T18:50:54+00:00\" \/>\n<meta name=\"author\" content=\"Stephanie Kahlam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Stephanie Kahlam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/\",\"url\":\"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/\",\"name\":\"Turning on Publishing with PowerShell in SharePoint Online - Stephanie Kahlam\",\"isPartOf\":{\"@id\":\"https:\/\/regroove.ca\/stellark\/#website\"},\"datePublished\":\"2016-04-02T19:29:36+00:00\",\"dateModified\":\"2023-02-24T18:50:54+00:00\",\"author\":{\"@id\":\"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/175e89cb69612178b2ac838c0bab6149\"},\"breadcrumb\":{\"@id\":\"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Stellark Home\",\"item\":\"https:\/\/regroove.ca\/stellark\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Turning on Publishing with PowerShell in SharePoint Online\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/regroove.ca\/stellark\/#website\",\"url\":\"https:\/\/regroove.ca\/stellark\/\",\"name\":\"Stephanie Kahlam\",\"description\":\"Microsoft 365 and SMB.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/regroove.ca\/stellark\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/175e89cb69612178b2ac838c0bab6149\",\"name\":\"Stephanie Kahlam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/398b95e23dc9eaf37a780b86a239b485?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/398b95e23dc9eaf37a780b86a239b485?s=96&d=mm&r=g\",\"caption\":\"Stephanie Kahlam\"},\"url\":\"https:\/\/regroove.ca\/stellark\/author\/skahlam\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Turning on Publishing with PowerShell in SharePoint Online - Stephanie Kahlam","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\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/","og_locale":"en_US","og_type":"article","og_title":"Turning on Publishing with PowerShell in SharePoint Online - Stephanie Kahlam","og_description":"We came across a situation recently where we needed to enable Publishing (at the web level \u2013 ie. It was already on at the site collection level) using PowerShell. This was in the context of a script that created many Sub Sites (webs) based on an automated process. A good time to remind everyone that &hellip;","og_url":"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/","og_site_name":"Stephanie Kahlam","article_published_time":"2016-04-02T19:29:36+00:00","article_modified_time":"2023-02-24T18:50:54+00:00","author":"Stephanie Kahlam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Stephanie Kahlam","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/","url":"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/","name":"Turning on Publishing with PowerShell in SharePoint Online - Stephanie Kahlam","isPartOf":{"@id":"https:\/\/regroove.ca\/stellark\/#website"},"datePublished":"2016-04-02T19:29:36+00:00","dateModified":"2023-02-24T18:50:54+00:00","author":{"@id":"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/175e89cb69612178b2ac838c0bab6149"},"breadcrumb":{"@id":"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/regroove.ca\/stellark\/2016\/04\/02\/turning-on-publishing-with-powershell-in-sharepoint-online\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Stellark Home","item":"https:\/\/regroove.ca\/stellark\/"},{"@type":"ListItem","position":2,"name":"Turning on Publishing with PowerShell in SharePoint Online"}]},{"@type":"WebSite","@id":"https:\/\/regroove.ca\/stellark\/#website","url":"https:\/\/regroove.ca\/stellark\/","name":"Stephanie Kahlam","description":"Microsoft 365 and SMB.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/regroove.ca\/stellark\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/175e89cb69612178b2ac838c0bab6149","name":"Stephanie Kahlam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/398b95e23dc9eaf37a780b86a239b485?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/398b95e23dc9eaf37a780b86a239b485?s=96&d=mm&r=g","caption":"Stephanie Kahlam"},"url":"https:\/\/regroove.ca\/stellark\/author\/skahlam\/"}]}},"_links":{"self":[{"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/posts\/920"}],"collection":[{"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/comments?post=920"}],"version-history":[{"count":1,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/posts\/920\/revisions"}],"predecessor-version":[{"id":1427,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/posts\/920\/revisions\/1427"}],"wp:attachment":[{"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/media?parent=920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/categories?post=920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/tags?post=920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}