SharePoint Online: Hide a Content Type using PowerShell

Requirement: Hide a Content Type in SharePoint Online

PowerShell to hide a Content Type in SharePoint Online:

If you want to keep certain content types hidden from your users, or if you need to temporarily remove a content type from use, You can hide that content type! This blog post will show you how to hide a content type using PowerShell.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Config Parameters
$ContentTypeName="Business Contacts"

Try {
    #Get Credentials to connect
    $Cred= Get-Credential

    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
    #Get the content type from the web
    $ContentTypeColl = $Ctx.Web.ContentTypes
    #Get the content type to Add
    $CType = $ContentTypeColl | Where {$_.Name -eq $ContentTypeName}
    If($CType -ne $Null)
        $CType.Group = "_Hidden"

        Write-host "Content Type Set Hidden!" -ForegroundColor Green
        Write-host "Content Type Doesn't Exist!" -ForegroundColor Yellow
Catch {
    write-host -f Red "Error Hiding the Content Type!" $_.Exception.Message

This moves the content type to Hidden group – which hides the content type from site settings >> Site Content Types page! Also, this content type will not be listed in the available content types dropdown when you try to add any existing content type to a list or library.

To hide a content type from the new button drop-down in SharePoint Online list settings page, use: SharePoint Online: Hide Content Type from dropdown

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *