Saturday, May 30, 2015

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()



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...