Can't turn off "Visible on New Button" for Content Type using PnP PowerShell

Brass Contributor



I'm having trouble turning off the "Visible on New Button" option for a Content Type on a Document Library.  I'm trying to use the "UniqueContentTypeOrder" to do that.  


So far, it's not taking -- any thoughts?  Snippet of script below.

Many thanks.


$doclib = Get-PnPList -Identity "Quotes" -Includes RootFolder.UniqueContentTypeOrder
$lct = $doclib.ContentTypes
$rootFolder = $doclib.RootFolder
$lucto = $doclib.ContentTypes | ?{$_.Name -ne "<Content Type I'm Trying to Hide>"}
$list = New-Object 'System.Collections.Generic.List[Microsoft.SharePoint.Client.ContentTypeId]'
foreach ($i in $lucto) {
    $id = $i.Id
$rootFolder.UniqueContentTypeOrder = $list
4 Replies

Shouldn't you have 


at the end? 


Haven't done this in powershell but the used method is the right one. 

I don't think that there is an option for this in PnP PowerShell. 

Thanks. Yeah, I tried that, but it errors (as is very common!) :( Not having much fun with SharePoint today

@Darren Parkinson Try Invoke-PnPQuery, you dont need to use ctx at all.


Working Code for me (I'm using the opposite approach, telling the function what content type I want to have in the "New" menu):


function SetVisibleContentType($listName, $ctName) {
    $ct = Get-PnPContentType -List $listName -Identity $ctName

    $list = Get-PnPList -Identity $listName -Includes RootFolder.UniqueContentTypeOrder

    $idList = New-Object "System.Collections.Generic.List[Microsoft.SharePoint.Client.ContentTypeId]"

    $list.RootFolder.UniqueContentTypeOrder = $idList



If you want to show more than one content type, just pass a string-array of content type names, or change the logic to show all but the provided conten type name.