Today I will be sharing a PnP based PowerShell script which can be used to update the properties for a column in a SharePoint Content Type. In the example, I am updating the property for one field but you can extent it further as per your needs.

In this example I have first loaded the content type using context object, then have loaded all the fields for that content type and then loaded the properties for the field before update. Below is the script for updating SharePoint Content type column properties:

#Get current Context
$cx = Get-PnPContext
 
#Give target content type name over here
$contentType = Get-PnPContentType -Identity "MSTech Contact ContentyType"
 
# Load all content type and its fields
$cx.Load($contentType)
$cx.Load($contentType.Fields) 
$cx.ExecuteQuery()
 
# Get required field from the target content type
# Mention field internal name or display name over here
$spField = $contentType.Fields.GetByInternalNameOrTitle("ContactNumber") 
$cx.Load($spField) 
$cx.ExecuteQuery()
 
#Update content type column to required
$contentType.FieldLinks.
GetById($spField.Id).Required = 1 
$contentType.Update(0) # Update children content type(inheriting from this Content Type) needs to be updated. 0 = False, 1 = True
$cx.ExecuteQuery()

Adnan is six time Microsoft MVP (Since 2015) with over 16 years of extensive experience with major expertise on SharePoint, SharePoint based development, Microsoft 365, Microsoft Teams, .Net Platform and Microsoft BI. He is currently working Sr Microsoft Consultant at Olive + Goose. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past 12 years and worked on different intranet/intranet solutions for private & govt. sector majorly in United states and Gulf region and have experience of working with multiple Fortune 500 companies. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply