I just used follwing script to change content type files in a document library but it seems that it works only on old files. the files must be created some time before you run the script. It is even not possible to change the content type by using GUI even I am Farm Admin.

I think you can change content type if you have files in the list have created earlier than 48 hours or something. Here is the script, no errors or problem with the script

    $listItem["ContentTypeId"] = $MyCTID
    $listItem.File.CheckIn("Content type changed to " + $MyCT.Name, 1)

I have tested with/without SystemUpdate() and with/without checkout checkin.

  • Are you asking how you change the content type for new files added to the document library? Commented May 10, 2012 at 14:09

1 Answer 1


I just tried it myself and it worked fine. Make sure if you have the content type configured on the document library beforehand.

  • Hi, Thanks, It is strange, because it changes som files but not all. what do you mean exactly "content type configured" because I usualy get the content type from the list: $MyCT = myList.ContentTypes["myContentType"] do you tried to add a new document to the list and after that change the content type of the document? first when you add the documenet must have default contenet type of the list and then try to change the content type to another which was added to the list.
    – Medes
    Commented May 11, 2012 at 11:36
  • When I say content type configured I mean the list must have the content type added before running the code. And yes I tried the same steps you mentioned.
    – Emon
    Commented May 12, 2012 at 13:09
  • Sometimes it is impossible change the content type of the document even by using GUI. so it must be something which prevents it.
    – Medes
    Commented May 13, 2012 at 20:58

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.