I have 30 CTs that I want to add to 20+ Site Collections. I have found a PowerShell script that can deploy a CT with a FIELD and parent but was after doing this in one go or just changing the URL variable and then running the script once for every SC. here is the PS...

$site = get-spsite $url

$web = $site.openweb()

$ctypeName = “myName”

$ctypeParent = $web.availablecontenttypes["Document"]

$ctype = new-object Microsoft.SharePoint.SPContentType($ctypeParent, $web.contenttypes, $ctypeName)


$web.fields.add(“myField”, ([Type]“Microsoft.SharePoint.SPFieldType”)::Text, $false)

$field = $web.fields.getfield(“myField”)

$fieldLink = new-object Microsoft.SharePoint.SPFieldLink($field)




  • with a filed means? and what exact problem are you facing? Commented Jul 7, 2014 at 10:25
  • FIELD, sorry. My problem is that I want to do this in a quick automated way instead of manually adding all 30 CTs to 20+ site collections
    – JazzyN
    Commented Jul 7, 2014 at 10:28

1 Answer 1


You can use an array to store the names of all the sitecollections like this

$siteCollectionUrls = @("siteUrl1", "siteUrl2", "siteUrl3")
for ($i=0; $i -lt $siteCollectionUrls .length; $i++) {
    $currentSiteUrl = $array[$i]
    # put logic for adding content types here

Similarly you can do kind of the same for iterating the content types in a inner loop for each site collection

  • Thanks both for your help. just realised I have an issue of assigning them to libraries not deploying them as we have a content hub
    – JazzyN
    Commented Jul 7, 2014 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.