I have used following power-shell script for creating a new content type with one custom column.
$siteURL = "My Site URL"
$contentTypeName = "Test Content Type 1"
$contentTypeGroupName = "Content Type Group Name"
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("System.Collections.Specialized")
$site = New-Object microsoft.sharepoint.spsite($siteURL)
$web = $site.openweb()
$cTypeID = $web.AvailableContentTypes["Item"]
$cTypes = $web.ContentTypes
$cType = New-Object Microsoft.SharePoint.SPContentType($cTypeID, $cTypes, $contentTypeName)
$cType.Group = $contentTypeGroupName
$cTypes.Add($cType)
$web.fields.add("myField2", ([Type]"Microsoft.SharePoint.SPFieldType")::Text, $false)
$field = $web.fields.getfield("myField2")
$fieldLink = new-object Microsoft.SharePoint.SPFieldLink($field)
$cType.fieldlinks.add($fieldLink)
$cType.Update()
$web.Dispose()
$site.Dispose()
This code creates the content type successfully and adds a site column to it.
But when i go to content type gallery and try to expand the content type. Only one field i.e. "myField2" is appearing in the list of columns. I was expecting "Title" field to also appear in the list, as its implicitly part of every custom content type. But its not there.
Can anybody explain why is it so ? or My understanding is wrong somewhere ?
Thanks in advance.