How to Change Column Type in SharePoint List using PowerShell?

Recently, There was a requirement to change column types from “Single line of text” to “Multiple Lines of Text” in multiple lists. Needless to say, PowerShell is the most efficient way to get such things done in bulk.

Here is the PowerShell Script to change column type in SharePoint programmatically:

PowerShell to Change Column Type in SharePoint

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get the Web where Lists Live
$web= Get-SPWeb "http://sharepoint.crescent.com/sites/Operations/"

#Define Array to hold Lists Names to Scan
$ListNames =  ("Design Documents", "Project Closure", "Metrics")

#Column to Change
$ColumnName ="Closing Notes"

 #Iterate through provided Lists 
foreach($ListName in $ListNames)
{
    #Get the List
    $list = $web.Lists.TryGetList($ListName) 
    if( $list -ne $null)
     {
        #Check if the list has our target column to change
        if($list.fields.ContainsField($ColumnName))
        {
           #Get the Column to Change
           $column = $List.Fields[$ColumnName]
   
           #Change the Column type to "Multiple Lines of Text"
           $column.Type = [Microsoft.SharePoint.SPFieldType]::Note
           $column.Update()
           Write-Host "Field type updated on: $($List.Title)"
        }
    }
}

$web.Dispose()

Done! Check SPFieldType in MSDN to get all available column types in SharePoint.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

One thought on “How to Change Column Type in SharePoint List using PowerShell?

  • May 22, 2015 at 12:13 PM

    Thanks for sharing the tip.
    The solution you gave indeed works, the problem is that the field schema can remain a bit inconsistent. The Type=”Text” is correctly changed into Type=”Note” but other artefacts can remain. For example, you may have MaxLength set in it, which is not supported for Note fields.
    It seems to be safer to replace the SchemaXml of the field altogether. You can take the old SchemaXml, change Type to Note, remove MaxLength, add NumLines if needed.
    This may look like (when altering a site column):
    [Microsoft.SharePoint.SPField]$field = $web.Fields.GetFieldByInternalName(“SingleLineToAlter”);
    $field.SchemaXml = ‘
    $field.Update($true)

    Reply

Leave a Reply