Table of Contents


Recently we were tasked with changing content types column settings to optional on a particular group, so when a migration happened it wouldn't require data to have information in columns. These groups had hundreds of columns within them and thus this script was born. It take some input from a user and check for all columns that are set to required and flip them to optional, while keeping a document of all the ones it's changed.

The Script

The script is available here

To start with we've got some parameters to make sure we use when running the script:

[Parameter(Mandatory=$true, HelpMessage="URL to the content type hub")][string]$ctHubURL,
[Parameter(Mandatory=$true, HelpMessage="Content type group you want to use")][string]$ctGroup,
[Parameter(Mandatory=$true, HelpMessage="Location of export file e.g. C:\Temp")][string]$ctFileLocation

ctHubURL - This will require the content hub url
ctGroup - The groups name of the content type you wish to change columns for
ctFileLocation - The location you wish to save the output csv to

.\ContentTypeColumnSettings.ps1 -ctHubURL "http://contoso/sites/contenttypehub" -ctGroup "ContentType Group" -ctFileLocation "C:\Temp"

Once entered you're promoted for an action on what you want to switch the columns to:

The default action by pressing enter is to switch all current columns that are required to optional. This will then create an output CSV of all the columns as well as showing you on screen the results:

This has now set all the columns to optional

Running the script again, you can choose R, and doing so will take the above CSV use the IDs and flip them back to their original value e.g. True

You could change this script to do ALL groups if you wanted, if you require help on this leave a comment