SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Are you asking how you change the content type for new files added to the document library? – Daniel Symonds-Lloyd May 10 '12 at 14:09

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

share|improve this answer
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 May 11 '12 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 May 12 '12 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 May 13 '12 at 20:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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