How to Read/Update Multiple lines of text Field Value in SharePoint using PowerShell?

PowerShell to Get Value from Multiple lines of text field:

To Read the value of multiline text field in SharePoint using PowerShell, use this script:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 

#configuration parameters
$WebURL="https://portal.crescent.com/selfservice/"
$ListName="Service Requests"
$ItemID=2
$FieldName="Request Description"

#Get Web, List, Item and Field
$Web= Get-SPWeb $WebURL
$List= $Web.Lists[$ListName]
$Item = $List.GetItembyID($ItemID)

#Get the field
$Field = $Item.Fields.GetField($FieldName)

#Retrieve field value with all formats applied
#$Field.GetFieldValueAsHTML($Item[$FieldName])
$MultilineValue=$Item[$FieldName]

#Get Field value Text alone -Without Formatting
$MultilineTextVale=$Field.GetFieldValueAsText($Item[$FieldName])

Update Multiple lines of text value using PowerShell:

Here is another example for updating Rich text field.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 

#configuration parameters
$WebURL="https://portal.crescent.com/selfservice/"
$ListName="Service Requests"
$ItemID=2
$FieldName="Request Description"

#Get Web, List, Item and Field
$Web= Get-SPWeb $WebURL
$List= $Web.Lists[$ListName]
$Item = $List.GetItembyID($ItemID)

#Update the field value
$Item[$FieldName]="Service Request No: 3435"
$Item.update()

#update HTML formatted value
#$Item[$FieldName]="Service Request No: <b> 3435</b>"
$Item.update()

Salaudeen Rajack

Information Technology Professional with Two decades of SharePoint Experience.

Leave a Reply