Changing required status for site columns in content type.
The required status for site columns have two options, required and optional .This script is to change required status for site columns in content type.
This script contains one advanced function Set-OSCContentTypeStatus, You can use this script in the following ways:
Method 1:
Method 2:
1. Rename scriptname.ps1 to scriptname.psm1 (PowerShell Module file)
2. Run Import-Module cmdlet to import this module file.
Import-Module filepath\scriptname.psm1
Example 1: Get help about Set-OSCContentTypeStatus
Command: Get-help Set-OSCContentTypeStatus -Full
Screenshot:

Example 2: Change required status for site columns in content type into required.
Command: Set-OSCContentTypeStatus -SiteUrl
"http://sp-server/sites/test1" -ContentName "Audio" -ColumnName "Preview" -Required
Screenshot:

Example 3: Change required status for site columns in content type into optional.
Command: Set-OSCContentTypeStatus -SiteUrl "http://sp-server/sites/test1" -ContentName "Audio" -ColumnName "Preview" -Optional
Screenshot:

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
$site=Get-SPSite -Identity $SiteUrl
$web=$site.RootWeb
$MyContentType=$web.ContentTypes[$ContentName]
$MyField=$MyContentType.Fields[$ColumnName]
If($Required)
{
$MyContentType.FieldLinks[$MyField.Id].Required=$true
}
Else
{
$MyContentType.FieldLinks[$MyField.Id].Required=$False
}
$MyContentType.Update($true)
Write-Host "The required status of $ColumnName has been changed!"
$site=Get-SPSite -Identity $SiteUrl $web=$site.RootWeb $MyContentType=$web.ContentTypes[$ContentName] $MyField=$MyContentType.Fields[$ColumnName] If($Required) { $MyContentType.FieldLinks[$MyField.Id].Required=$true } Else { $MyContentType.FieldLinks[$MyField.Id].Required=$False } $MyContentType.Update($true) Write-Host "The required status of $ColumnName has been changed!"
Technical Resource:
Get-Spsite
http://technet.microsoft.com/en-us/library/ff607950.aspx