Add and Remove Operation of Content Types in SharePoint Site Using PnP PowerShell.

In this blog, we will see how we can add a custom content type in SharePoint site using PnP PowerShell. Also, we will see how we can get a particular content type and remove it from the SharePoint site using PnP PowerShell.

Add Custom Content Type in SharePoint site: –

  • The following command snippet will help you to create the new content type in SharePoint site.
Add-PnPContentType -Name "Custom Content Type" -Description "Use for Custom projects" -Group "Custom Content Types" 
  • Also, the parent content type can be used as a base content type to create the new content types. The following example shows to create the  new content type, using the Project content type, given below:
$projectCT = Get-PnPContentType -Identity "Project"
Add-PnPContentType -Name "Custom Content Type" -Description "Use for Custom projects" -Group "Custom Content Types" -ParentContentType $projectCT 

Remove Content Type from SharePoint site:-

  •  In the following command snippet it will remove a content type called “Project” from the current web

Remove-PnPContentType -Identity “Project”

  • Following command snippet will remove a content type called “Project” from the current web with force

Remove-PnPContentType -Identity “Project ” -Force

Connect-PnPOnline –Url https://yoursite.sharepoint.com –Credentials (Get-Credential)

<#Add custom content type to your SharePoint site#>
Add-PnPContentType -Name "Custom Content Type" -Description "Use for Custom projects" -Group "Custom Content Types"

<#In the following command snippet parent content type is used as a base content type to create the new content type#>
$projectCT = Get-PnPContentType -Identity "Project"
Add-PnPContentType -Name "Custom Content Type" -Description "Use for Custom projects" -Group "Custom Content Types" -ParentContentType $projectCT

<#Remove a content type called "Project" from the current web#>
Remove-PnPContentType -Identity "Project"

<#Remove a content type called "Project" from the current web with force#>
Remove-PnPContentType -Identity "Project" -Force

Softree Consulting is an award-winning SharePoint consultancy that has been working with clients from across the globe to transform workplaces with tools and platforms from Microsoft technology. As a widely recognized organization, we are commonly approached to incorporate technical excellence and innovative design into all our customer actions.....

Site Footer