Convert all rich text fields to enhanced rich text in SharePoint 2013/2016

This script is really helpful when you are upgrading your SharePoint environment or in the scenario when InfoPath is not 100% supported in Edge browser.

All you have to do is replace "<WebApplication URL>" with the URL of the SharePoint web application you want to modify. Highly recommended to test in non-production environment.

This script will search the web application for lists that contain multiline rich text fields, and then convert those fields to enriched rich text fields. 

Note that this process will modify the field's data type and may impact any existing customizations or scripts that reference the field. It is recommended to backup your data and test the script in a non-production environment before executing it in a production environment.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
$webApp = Get-SPWebApplication "<Webapplication URL"
foreach ($site in $webApp.Sites) {
    foreach ($web in $site.AllWebs) {
        $lists = $web.Lists | Where-Object { $_.BaseTemplate -eq "GenericList" }
        foreach ($list in $lists) {
            foreach ($field in $list.Fields) {
                if ($field.TypeAsString -eq "Note" -and $field.RichText -eq $true) {
                    # Update the field type to enhanced rich text
					$Field.RichTextMode = "FullHtml"
					$Field.RichText = $True
					$field.Update()
					Write-Host "Converted rich text field '$($field.Title)' to enhanced rich text."
                }
            }
        }

        $web.Dispose()
    }

    $site.Dispose()
}


Comments

Popular posts from this blog

InfoPath to PowerApps: Best Practices

Create Azure AD groups from a CSV file

PowerApps Governance: What to consider