$site = get-spsite $url
$web = $site.openweb()
$ctypeName = “myName”
$ctypeParent = $web.availablecontenttypes["Document"]
$ctype = new-object Microsoft.SharePoint.SPContentType($ctypeParent, $web.contenttypes, $ctypeName)
$web.contenttypes.add($ctype)
$web.fields.add(“myField”, ([Type]“Microsoft.SharePoint.SPFieldType”)::Text, $false)
$field = $web.fields.getfield(“myField”)
$fieldLink = new-object Microsoft.SharePoint.SPFieldLink($field)
$ctype.fieldlinks.add($fieldLink)
$ctype.Update()
$web.Dispose()
$site.Dispose()

viaCreate a SharePoint 2010 Content Type using Powershell « SharePoint Thoughts.

Annunci