In this blog, we will see how we can add a custom content type in a 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 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”
- The 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:
- <#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