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

%3CLINGO-SUB%20id%3D%22lingo-sub-110468%22%20slang%3D%22en-US%22%3ECan't%20turn%20off%20%22Visible%20on%20New%20Button%22%20for%20Content%20Type%20using%20PnP%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-110468%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20having%20trouble%20turning%20off%20the%20%22Visible%20on%20New%20Button%22%20option%20for%20a%20Content%20Type%20on%20a%20Document%20Library.%20%26nbsp%3BI'm%20trying%20to%20use%20the%20%22UniqueContentTypeOrder%22%20to%20do%20that.%20%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20far%2C%20it's%20not%20taking%20--%20any%20thoughts%3F%20%26nbsp%3BSnippet%20of%20script%20below.%3C%2FP%3E%3CP%3EMany%20thanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24doclib%20%3D%20Get-PnPList%20-Identity%20%22Quotes%22%20-Includes%20RootFolder.UniqueContentTypeOrder%0A%24lct%20%3D%20%24doclib.ContentTypes%0A%24ctx.Load(%24lct)%0A%24ctx.ExecuteQuery()%0A%24rootFolder%20%3D%20%24doclib.RootFolder%0A%24lucto%20%3D%20%24doclib.ContentTypes%20%7C%20%3F%7B%24_.Name%20-ne%20%22%26lt%3BContent%20Type%20I'm%20Trying%20to%20Hide%26gt%3B%22%7D%0A%24list%20%3D%20New-Object%20'System.Collections.Generic.List%5BMicrosoft.SharePoint.Client.ContentTypeId%5D'%0Aforeach%20(%24i%20in%20%24lucto)%20%7B%0A%20%20%20%20%24id%20%3D%20%24i.Id%0A%20%20%20%20%24list.Add(%24id)%0A%7D%0A%24rootFolder.UniqueContentTypeOrder%20%3D%20%24list%0A%24rootFolder.Update()%0A%24doclib.Update()%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-110468%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-110560%22%20slang%3D%22en-US%22%3ERE%3A%20Can't%20turn%20off%20%22Visible%20on%20New%20Button%22%20for%20Content%20Type%20using%20PnP%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-110560%22%20slang%3D%22en-US%22%3EThanks.%20Yeah%2C%20I%20tried%20that%2C%20but%20it%20errors%20(as%20is%20very%20common!)%20%3A(%3C%2Fimg%3E%20Not%20having%20much%20fun%20with%20SharePoint%20today%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-110493%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20turn%20off%20%22Visible%20on%20New%20Button%22%20for%20Content%20Type%20using%20PnP%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-110493%22%20slang%3D%22en-US%22%3E%3CP%3EI%20don't%20think%20that%20there%20is%20an%20option%20for%20this%20in%20PnP%20PowerShell.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-110491%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20turn%20off%20%22Visible%20on%20New%20Button%22%20for%20Content%20Type%20using%20PnP%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-110491%22%20slang%3D%22en-US%22%3E%3CP%3EShouldn't%20you%20have%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24ctx.ExecuteQuery()%3C%2FPRE%3E%3CP%3Eat%20the%20end%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHaven't%20done%20this%20in%20powershell%20but%26nbsp%3Bthe%20used%20method%20is%20the%20right%20one.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi,

 

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
$ctx.Load($lct)
$ctx.ExecuteQuery()
$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
    $list.Add($id)
}
$rootFolder.UniqueContentTypeOrder = $list
$rootFolder.Update()
$doclib.Update()
3 Replies

Shouldn't you have 

$ctx.ExecuteQuery()

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