SharePoint List – Extract a MultiLine Text Field (HTML)

Ever wanted to extract a multiline text field from a SharePoint List.

And this in a fast way Smile

CLS

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$WebURL = "http://YourSite/"

#List
$listName = "YourList"

#Activity
$ID = "1"
$TextField = "Your MultiLine Text Field Name"

#Get the Web & Lists using the SPQuery (fast way)
$Web = Get-SPWeb $WebURL

        #$WebUrl = $site.OpenWeb()
        $list = $web.Lists[$listName]

        $query = New-Object Microsoft.SharePoint.SPQuery

        $query.RowLimit = 100

        $query.Query = "<where><eq><fieldref name="ID" /><value type=" Number">"+$ID+"</value></eq></where>"

        $items = $list.GetItems($query)

            foreach($item in $items){

            Write-Host "ID = " $item.ID

            Write-Host "Activity ID : " $item.ID "-" $item.Title -nobr
            Write-Host ""

            Write-Host $Text
  }

Notice the CAML query that grabs the record ID first. That will speed up the process tremendously.

Enjoy!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: