kwizcom banner advertisement

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:
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: <br/> <b> 3435</b>"
$Item.update()
How to Read-Update Multiple lines of text Field Value in SharePoint using Powershell? How to Read-Update Multiple lines of text Field Value in SharePoint using Powershell? Reviewed by Salaudeen Rajack on May 30, 2015 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.