Forum Discussion
Rod Le Quesne
Jan 10, 2017Copper Contributor
PnP powershell equivant - Hide content type from new menu
Is there a method to hide content type from the 'new' menu on a list in the same way using the UI located at _layouts/15/ChangeContentTypeOrder.aspx. I have tried using following script, issue here i...
avdberg
Nov 29, 2018Copper Contributor
You can do that with the following code:
$contentTypeNamesInOrder = "Sub Project"
$contentTypes = $projectInformationList.ContentTypes
$ctx.Load($contentTypes)
$ctx.Load($projectInformationList.RootFolder)
$ctx.ExecuteQuery()
$ctList = New-Object System.Collections.Generic.List[Microsoft.SharePoint.Client.ContentTypeId]
Foreach($ct in $contentTypeNamesInOrder){
$ctToInclude = $contentTypes | Where-Object {$_.Name -eq $ct}
$ctList.Add($ctToInclude.Id)
}
#Updating content type order and visibility
$projectInformationList.RootFolder.UniqueContentTypeOrder = $ctList
$projectInformationList.Update()
$projectInformationList.RootFolder.Update()
$ctx.ExecuteQuery()