none
Powershell cmd to change Multiple Line of Text column from Plain Text to Enhanced Rich Text?

    Question

  • I have a bunch of columns that were setup as Multiple Lines of Text - Plain Text type columns and I want to change them to be Multiple Lines of Text - Enhanced Rich Text type columns.

    Is there a powershell command that can do this?

    Thursday, December 22, 2011 6:04 PM

Answers

  • Hi Fubak,

    For the last 15 minutes I have been testing this, and I think i have a solution.

    The example I am giving will just change 1 site column, but I guess you can loop through a csv to get what you need.

    Here is what I got (and tested on my dev environment):

    $Web = Get-SPWeb "yoururl.domain.com/particularweb"
    $Field = $web.Fields | ?{$_.staticname -eq "MyCustomColumn"}
    $Field.RichText = $True
    $Field.RichTextMode = "FullHtml"
    $Field.Update()
    
    

    I suggest you first test the above script, since it has just been 15 minutes of testing on my environment. I will be testing some more, and if I find something interesting I will let you know.

    I hope it helped. 


    Kind regards,

    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant
    Blog: SharePoint Related
    E-mail: Nico Martens

    • Edited by Nico Martens Thursday, December 22, 2011 7:00 PM
    • Marked as answer by BradShannon Thursday, December 22, 2011 9:26 PM
    Thursday, December 22, 2011 6:45 PM

All replies

  • Hi Fubak,

    For the last 15 minutes I have been testing this, and I think i have a solution.

    The example I am giving will just change 1 site column, but I guess you can loop through a csv to get what you need.

    Here is what I got (and tested on my dev environment):

    $Web = Get-SPWeb "yoururl.domain.com/particularweb"
    $Field = $web.Fields | ?{$_.staticname -eq "MyCustomColumn"}
    $Field.RichText = $True
    $Field.RichTextMode = "FullHtml"
    $Field.Update()
    
    

    I suggest you first test the above script, since it has just been 15 minutes of testing on my environment. I will be testing some more, and if I find something interesting I will let you know.

    I hope it helped. 


    Kind regards,

    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant
    Blog: SharePoint Related
    E-mail: Nico Martens

    • Edited by Nico Martens Thursday, December 22, 2011 7:00 PM
    • Marked as answer by BradShannon Thursday, December 22, 2011 9:26 PM
    Thursday, December 22, 2011 6:45 PM
  • Great reply Nico.  Thanks!  I'll test ASAP and report back.
    Thursday, December 22, 2011 6:47 PM
  • After some extra comparing of a newly created "Enhanced Rich Text" and the one i converted to Enhanced Rich Text, I cannot find any differences, except for the obvious: Title, StaticName, InternalName, ID etc.


    Kind regards,

    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant
    Blog: SharePoint Related
    E-mail: Nico Martens
    Thursday, December 22, 2011 6:50 PM
  • It looks like that worked.  Thanks Nico!!
    Thursday, December 22, 2011 9:27 PM
  • Hi Nico,

    Thanks for your answer, but i don't know where i need to use this scripts, will you guide me where/how i need to put this scripts.

    thanks

    Tuesday, March 20, 2012 6:18 AM
  • Hi Karthickr,

    Change the bold items and paste it into the SharePoint 2010 Management Shell (as administrator).

    $Web = Get-SPWeb "yoururl.domain.com/particularweb"
    $Field = $web.Fields | ?{$_.staticname -eq "MyCustomColumn"}
    $Field.RichText = $True
    $Field.RichTextMode = "FullHtml"
    $Field.Update()
    


    Kind regards,

    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant
    Blog: SharePoint Related
    E-mail: Nico Martens

    Wednesday, March 21, 2012 6:35 AM
  • Hi Nico Martens,

    Thanks  for your reply, it works perfectly.

    Regards,

    Karthick

    Wednesday, April 18, 2012 6:31 AM
  • I would like to say thank you, this script works great and if this is the wrong place to post this please let me know.

    I am trying to write in some error checking (1)To see if Pages exists, otherwise move on. (2)Check to see if Additional Page Content field is there, if not move on. (3) Check the fields Richtext and richtextmode are set to $true and FullHtml, respectivly.

    My code works for (1)(2) but not for (3). As a result of trial and error, I have narrowed it down to when the $field.Update() trys to run with the IF statement there. It doesn't seem to matter where the update() is, inside the IF or outside it.  It does work however without the IF ELSE statement there.

    I must state that I am still new to powershell and sharepoint, but I am learning it. any help would be appreciated.

    #Add in all of the sharepoint snapins here

    $web = Get-SPWeb <URL GOES HERE>
    $list = $web.Lists["Pages"] $field = $list.Fields.Getfield("Additional Page Content") Write-output "`nCurrent: $($field.richtext) $($field.richtextmode)`n" $test = $($field | Select-Object richtextmode -ExpandProperty richtextmode) $test1 = "FullHtml" $comp = [string]::Compare($test, $test1, $true) Write-Output "Test: $($test) Test1: $($test1) resault: $($comp)`n" if($comp -eq 0){ Write-Host "NO CHANGE"-BackgroundColor Yellow -ForegroundColor Black } else{ $field.richtext = $ture $field.RichTextMode = "FullHtml" $field.Update(); }

    Friday, June 21, 2013 9:45 PM
  • I follow the instructions exactly. After I retrieve the $Field, the value of $Field.RichText is $False.

    I change RichText and RichTextMode according to instructions and call Update() on the Field. I also verify that the values are updated by calling $Field.RichText and $Field.RichTextMode from PowerShell.

    However, when I go back to the form New/Update, the field is still multi-lines plain text.

    I am pretty sure I am updating the correct field as it has a very unique static name and it is only used in one content type in the site collection.

    What have I possibly done wrong? :(


    MCTS SharePoint 2007 MCITP SharePoint 2010 OCA BCCPA

    Friday, September 20, 2013 9:57 AM
  • After pulling my hair for a while, I decided to create a new column in RichTextMode, do some powershell script to copy the values from the old column to the new one and then remove the old column after verifying the data in the new RichText column.


    MCTS SharePoint 2007 MCITP SharePoint 2010 OCA BCCPA

    Wednesday, September 25, 2013 2:56 AM