Skip to content
Rishan Solutions
Rishan Solutions
  • PowerApps
  • SharePoint online
    • Uncategorized
    • Uncategorized
  • PowerAutomate
Rishan Solutions
Latest Posts
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025 June 24, 2025
  • Recursive Queries in T-SQL May 7, 2025
  • Generating Test Data with CROSS JOIN May 7, 2025
  • Working with Hierarchical Data May 7, 2025
  • Using TRY_CAST vs CAST May 7, 2025
  • Dynamic SQL Execution with sp_executesql May 7, 2025

Creating and Managing SharePoint Content Types using PnP PowerShell

Posted on March 19, 2025March 19, 2025 by Rishan Solutions

Loading

SharePoint Content Types are essential for managing structured content across sites. They define metadata, workflows, and templates for items such as documents, list items, and pages.

With PnP PowerShell, we can automate the creation, modification, and management of Content Types, ensuring consistency and efficiency in SharePoint Online.

This guide provides a step-by-step approach to managing SharePoint Content Types using PnP PowerShell.


Prerequisites

PnP PowerShell Installed
Install it using:

Install-Module -Name PnP.PowerShell -Force -AllowClobber

Administrator Permissions

  • You must be a SharePoint Admin or Site Collection Admin.

Connect to SharePoint Online

Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/YourSite" -Interactive

Step 1: Retrieve Existing Content Types

Before creating a new Content Type, check the existing ones:

# Get all Content Types in the Site
Get-PnPContentType

To check a specific Content Type:

powershellCopyEditGet-PnPContentType -Identity "0x010100D5F4A3B2483A4B8E947FBEA3E4B4A609"

🔹 The ID helps ensure uniqueness when creating new Content Types.


Step 2: Create a New Content Type

A Content Type requires a Name, ID, and Parent Content Type.

New-PnPContentType -Name "Project Document" -Group "Custom Content Types" -Description "Project-related documents" -ParentContentType "0x0101"

Creates a Project Document Content Type under Custom Content Types.
0x0101 is the ID for the Document Content Type.


Step 3: Add Site Columns to the Content Type

To store metadata, add columns to the Content Type:

# Create a new column
Add-PnPField -DisplayName "Project Name" -InternalName "ProjectName" -Type Text -Group "Custom Columns"

# Add the column to the Content Type
Add-PnPFieldToContentType -Field "ProjectName" -ContentType "Project Document"

Adds a “Project Name” column to “Project Document” Content Type.


Step 4: Assign Content Type to a Library or List

Now, apply the Content Type to a Document Library:

# Enable content types in the library
Set-PnPList -Identity "Project Documents" -ContentTypesEnabled $true

# Add the content type to the library
Add-PnPContentTypeToList -List "Project Documents" -ContentType "Project Document"

Enables Content Types in the Project Documents library.
Assigns the Project Document Content Type to the library.


Step 5: Update an Existing Content Type

To rename or update a Content Type:

Set-PnPContentType -Identity "Project Document" -Name "Updated Project Document"

Renames Project Document to Updated Project Document.


Step 6: Remove a Content Type from a Library

To unassign a Content Type from a list:

Remove-PnPContentTypeFromList -List "Project Documents" -ContentType "Updated Project Document" -Confirm:$false

Removes Updated Project Document from Project Documents library.


Step 7: Delete a Content Type

To delete an unused Content Type:

Remove-PnPContentType -Identity "Updated Project Document" -Confirm:$false

Warning: This action cannot be undone. Ensure no dependencies exist before deleting.


Step 8: Export Content Types to CSV

To back up all Content Types and their columns:

$contentTypes = Get-PnPContentType
$contentTypes | Select Name, Id, Group, Description | Export-Csv -Path "C:\SharePoint_ContentTypes.csv" -NoTypeInformation

Saves all Content Types and metadata to a CSV file.


Step 9: Import Content Types from CSV (Bulk Creation)

Prepare a CSV file with the format:

NameGroupParentContentTypeDescription
Invoice DocumentCustom Content Types0x0101Stores invoice documents
HR PoliciesCustom Content Types0x0101Stores HR policy documents

Run the script to create them in bulk:

$csvData = Import-Csv -Path "C:\SharePoint_ContentTypes.csv"

foreach ($row in $csvData) {
New-PnPContentType -Name $row.Name -Group $row.Group -ParentContentType $row.ParentContentType -Description $row.Description
}

Creates multiple Content Types in SharePoint from the CSV file.


Step 10: Schedule the Script for Automation

1️⃣ Open Task Scheduler
2️⃣ Click Create Basic Task
3️⃣ Set Trigger: Daily/Weekly
4️⃣ Set Action: Start a Program
5️⃣ In Program/script, enter:

-ExecutionPolicy Bypass -File "C:\YourScriptPath\ManageContentTypes.ps1"

6️⃣ Click Finish

🔹 The script now runs automatically based on schedule.


Troubleshooting Common Issues

Issue 1: PnP PowerShell Not Recognized

Run:

Update-Module -Name PnP.PowerShell

Issue 2: Connection Errors

Ensure you are connected as Admin:

Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/YourSite" -Interactive

Issue 3: Content Type Not Appearing in Library

  • Ensure Content Types are enabled in the Library.
  • Check if the Content Type was correctly assigned.
Posted Under PNP PowerShellBusiness Process Automation cloud computing Content Type Automation Content Type Inheritance Content Types Custom Columns data governance Digital Transformation Document Management Enterprise Content Management Information Architecture IT Automation list management Metadata Management Microsoft 365 Office 365 PNP PowerShell PowerShell scripting SharePoint SharePoint Automation SharePoint Best Practices SharePoint Compliance SharePoint Customization SharePoint Governance SharePoint Metadata SharePoint online

Post navigation

IoT in Industrial Safety and Hazard Monitoring
IoT for Supply Chain Optimization

Leave a Reply Cancel reply

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

Recent Posts

  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025
  • Recursive Queries in T-SQL
  • Generating Test Data with CROSS JOIN
  • Working with Hierarchical Data
  • Using TRY_CAST vs CAST

Recent Comments

  1. Michael Francis on Search , Filter and Lookup in power apps
  2. A WordPress Commenter on Hello world!

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • January 2022

Categories

  • Active Directory
  • AI
  • AngularJS
  • Blockchain
  • Button
  • Buttons
  • Choice Column
  • Cloud
  • Cloud Computing
  • Data Science
  • Distribution List
  • DotNet
  • Dynamics365
  • Excel Desktop
  • Extended Reality (XR) – AR, VR, MR
  • Gallery
  • Icons
  • IoT
  • Java
  • Java Script
  • jQuery
  • Microsoft Teams
  • ML
  • MS Excel
  • MS Office 365
  • MS Word
  • Office 365
  • Outlook
  • PDF File
  • PNP PowerShell
  • Power BI
  • Power Pages
  • Power Platform
  • Power Virtual Agent
  • PowerApps
  • PowerAutomate
  • PowerPoint Desktop
  • PVA
  • Python
  • Quantum Computing
  • Radio button
  • ReactJS
  • Security Groups
  • SharePoint Document library
  • SharePoint online
  • SharePoint onpremise
  • SQL
  • SQL Server
  • Template
  • Uncategorized
  • Variable
  • Visio
  • Visual Studio code
  • Windows
© Rishan Solutions 2025 | Designed by PixaHive.com.
  • Rishan Solutions