{"id":1387,"date":"2018-03-26T22:31:23","date_gmt":"2018-03-26T21:31:23","guid":{"rendered":"http:\/\/www.myfatblog.co.uk\/?p=1387"},"modified":"2018-03-26T22:31:23","modified_gmt":"2018-03-26T21:31:23","slug":"contenttypes-added-spo-using-pnp-posh-not-working-intended","status":"publish","type":"post","link":"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/","title":{"rendered":"ContentTypes added to SPO using PNP PoSH not working as intended!"},"content":{"rendered":"<p>I\u2019m in the process of building a large scale DMS solution for a client and part of this work is deploying a lot of content types to various libraries. I wrote the deployment scripts a couple of months ago and they have been working just fine.. or so I thought.<\/p>\n<p>I\u2019m using the PNP PowerShell cmdlets to abstract a lot of the CSOM work away from me having to do it.. after all, why reinvent the wheel? If you haven\u2019t looked at the PNP PowerShell project then why on earth not? It makes writing scripts against SharePoint Online so much easier! (<a href=\"https:\/\/github.com\/SharePoint\/PnP-PowerShell\">See here for more details<\/a>..)<\/p>\n<p>I\u2019m using the simply named add-pnpcontenttypetolist to add an existing set of ContentTypes to a document library. The ContentTypes have already been defined in the root of the Site Collection and for the purposes of showing you the issue, I\u2019m executing the following lines of code (after connecting to the Site of course)<\/p>\n<p><strong><em>Add-PnPContentTypeToList -List $docLib -ContentType &#8220;Test CTYPE A&#8221; -DefaultContentType<br \/>\nAdd-PnPContentTypeToList -List $docLib -ContentType &#8220;Test CTYPE B&#8221;<br \/>\nAdd-PnPContentTypeToList -List $docLib -ContentType &#8220;Test CTYPE C&#8221;<br \/>\nAdd-PnPContentTypeToList -List $docLib -ContentType &#8220;Test CTYPE D&#8221;<\/em><\/strong><\/p>\n<p>Nothing earth shattering there, but when we look at our List settings afterwards, you may spot a problem.<\/p>\n<p><a href=\"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" style=\"border: 0px currentcolor; display: inline; background-image: none;\" title=\"SNAGHTML1c631e91\" src=\"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png\" alt=\"ContentTypes list before fix\" width=\"613\" height=\"248\" border=\"0\" \/><\/a><\/p>\n<p>As you can see, 3 of our ContentTypes have been added, but aren\u2019t active in the list, therefore we can\u2019t create documents using them and if we opened the property pane for a document, we wouldn\u2019t be able to select the content type for an item either.<\/p>\n<p>I had a look around and it had been raised as an issue with the PNP team in their <a href=\"https:\/\/github.com\/SharePoint\/PnP-PowerShell\/issues\/1101\">GitHub Issues<\/a> list, but having done further testing using CSOM directly, I think we can safely say this is an underlying bug with the CSOM code rather than a PNP issue.<\/p>\n<p>Luckily there is a workaround, You just need to add all of your ContentTypes to the list, then call the Set-PnPDefaultContentTypeToList against your required CType afterwards, This seems to activate all of the ContentTypes on the list as a side effect.<\/p>\n<p><strong><em>Set-PnPDefaultContentTypeToList -List $docLib -ContentType &#8220;Test CTYPE B&#8221;<\/em><\/strong><\/p>\n<p><a href=\"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/image.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" style=\"display: inline; background-image: none;\" title=\"image\" src=\"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/image_thumb.png\" alt=\"ContentTypes list after fix\" width=\"413\" height=\"181\" border=\"0\" \/><\/a><\/p>\n<p>Not ideal, but a workaround will do.<\/p>\n<p>Paul.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019m in the process of building a large scale DMS solution for a client and part of this work is deploying a lot of content types to various libraries. I wrote the deployment scripts a couple of months ago and they have been working just fine.. or so I thought. I\u2019m using the PNP PowerShell &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[94,245,110,139],"tags":[116,246,56],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ContentTypes added to SPO using PNP PoSH not working as intended! - Blog of an overweight SharePoint addict<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ContentTypes added to SPO using PNP PoSH not working as intended! - Blog of an overweight SharePoint addict\" \/>\n<meta property=\"og:description\" content=\"I\u2019m in the process of building a large scale DMS solution for a client and part of this work is deploying a lot of content types to various libraries. I wrote the deployment scripts a couple of months ago and they have been working just fine.. or so I thought. I\u2019m using the PNP PowerShell &hellip; Continue reading\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog of an overweight SharePoint addict\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-26T21:31:23+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png\" \/>\n<meta name=\"author\" content=\"Cimares\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cimares\" \/>\n<meta name=\"twitter:site\" content=\"@cimares\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Cimares\" \/>\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\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/\",\"name\":\"ContentTypes added to SPO using PNP PoSH not working as intended! - Blog of an overweight SharePoint addict\",\"isPartOf\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png\",\"datePublished\":\"2018-03-26T21:31:23+00:00\",\"dateModified\":\"2018-03-26T21:31:23+00:00\",\"author\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/#primaryimage\",\"url\":\"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png\",\"contentUrl\":\"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png\",\"width\":613,\"height\":248},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\",\"url\":\"http:\/\/www.myfatblog.co.uk\/\",\"name\":\"Blog of an overweight SharePoint addict\",\"description\":\"The rantings of a (not so) food obsessed IT consultant!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\",\"name\":\"Cimares\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"contentUrl\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"caption\":\"Cimares\"},\"sameAs\":[\"http:\/\/www.myfatblog.co.uk\"],\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ContentTypes added to SPO using PNP PoSH not working as intended! - Blog of an overweight SharePoint addict","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":"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/","og_locale":"en_US","og_type":"article","og_title":"ContentTypes added to SPO using PNP PoSH not working as intended! - Blog of an overweight SharePoint addict","og_description":"I\u2019m in the process of building a large scale DMS solution for a client and part of this work is deploying a lot of content types to various libraries. I wrote the deployment scripts a couple of months ago and they have been working just fine.. or so I thought. I\u2019m using the PNP PowerShell &hellip; Continue reading","og_url":"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/","og_site_name":"Blog of an overweight SharePoint addict","article_published_time":"2018-03-26T21:31:23+00:00","og_image":[{"url":"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png"}],"author":"Cimares","twitter_card":"summary_large_image","twitter_creator":"@cimares","twitter_site":"@cimares","twitter_misc":{"Written by":"Cimares","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/","url":"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/","name":"ContentTypes added to SPO using PNP PoSH not working as intended! - Blog of an overweight SharePoint addict","isPartOf":{"@id":"http:\/\/www.myfatblog.co.uk\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/#primaryimage"},"image":{"@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/#primaryimage"},"thumbnailUrl":"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png","datePublished":"2018-03-26T21:31:23+00:00","dateModified":"2018-03-26T21:31:23+00:00","author":{"@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2018\/03\/contenttypes-added-spo-using-pnp-posh-not-working-intended\/#primaryimage","url":"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png","contentUrl":"http:\/\/www.myfatblog.co.uk\/wp-content\/uploads\/2018\/03\/SNAGHTML1c631e91_thumb.png","width":613,"height":248},{"@type":"WebSite","@id":"http:\/\/www.myfatblog.co.uk\/#website","url":"http:\/\/www.myfatblog.co.uk\/","name":"Blog of an overweight SharePoint addict","description":"The rantings of a (not so) food obsessed IT consultant!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6","name":"Cimares","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/","url":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","contentUrl":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","caption":"Cimares"},"sameAs":["http:\/\/www.myfatblog.co.uk"],"url":"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/"}]}},"_links":{"self":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/1387"}],"collection":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=1387"}],"version-history":[{"count":2,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/1387\/revisions"}],"predecessor-version":[{"id":1390,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/1387\/revisions\/1390"}],"wp:attachment":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=1387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=1387"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=1387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}