M365 Dev Blog

Easily force content type updates in SharePoint on-prem

There is a simple way to force content type updates in SharePoint via Site Settings. But how can we easily do the same in a quick and simple way using PowerShell? In this post you will learn how to easily force content type updates in SharePoint on-prem.

Force content type updates via settings page

Forcing a content type update via the content type settings page in SharePoint is very simple.

Go to the Site settings page on your site, and then to the Site Content Types page. Select the content type to update.

Content type settings page

Now one thing to keep in mind: if you want your update to propagate to all places where the content type is used, you should make a significant change to the content type. If you only update the description, as an example, updates are not propagated.

In this case, a common approach that I use is to update the Column order.

When changing the column order, just ensure that “Update Sites and Lists” is set to “Yes”.

Force content type updates in SharePoint

Once the update completes, revert to the original order and update again. I used this approach many times and always had the expected result.
But what if we need to update a large number of content types? Then we need to script it…

Force content type updates via PowerShell

To force content type updates via PowerShell, I will use the same approach described above: update column order and revert changes.
For relevant changes, like adding a new column to the content type, the Update($true) method will handle things as expected. The $true parameter will force the update as described in the documentation.
The problem is when you don’t really want to add or apply changes to fields. In this case, we can easily force content type updates in SharePoint on-prem by executing a reorder.

# force update on order of fields to force propagation of changes
$ctFieldLinksOrder = @($contentType.FieldLinks.Name)
# create temp fields order
$tempCTFieldLinksOrder = $ctFieldLinksOrder | Select-Object -Skip 1 # remove first item from array
$tempCTFieldLinksOrder += $ctFieldLinksOrder[0] # add first array item at the end
# temporary change to fields order to force updates
$contentType.FieldLinks.Reorder($tempCTFieldLinksOrder)
$contentType.Update($true)
# restore original fields order
$contentType.FieldLinks.Reorder($ctFieldLinksOrder)
$contentType.Update($true)

This will achieve the same result as reordering the fields from the settings page, and all content type instances with receive updates.

Exit mobile version