SP Online ClientContext.Load syntax for specific fields only RRS feed

  • Question

  • What is the correct syntax in the PowerShell CSOM for SharePoint Online to retrieve only a few columns from a list instead of all columns ? I only need to fetch the columns in the write-host statement. The => syntax that is found in many code examples does not seem to work in the online CSOM.

    $poslist = $web.Lists.GetByTitle("Points of Sale")
    $caml = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery()
    $items = $poslist.GetItems($caml)
    foreach ($item in $items)
        Write-host $item["Title"] $item["Brand"] $item["Name"] $item["Contact"].LookupValue


    • Edited by S Bouillon Tuesday, March 14, 2017 5:19 PM
    Tuesday, March 14, 2017 5:17 PM

All replies

  • Hi Bouillon,

    Did you try like this:

    Load-CSOMProperties -parentObject $web -collectionObject $web.Lists -propertyNames @("Id", "Title") -parentPropertyName "Lists"




    Please mark as answer, if my solution helps you.

    Tuesday, March 14, 2017 6:43 PM
  • Thanks for your time and effort,

    The article points to a function that is really a helper function, see for the full code.

    What I was wondering is if there is a standard way of doing this in the SharePoint online csom syntax itself. There seems to be very little documentation on this.


    Tuesday, March 14, 2017 9:07 PM
  • Please mark as answer as it will helps to others also.
    Tuesday, March 14, 2017 9:15 PM
  • I don't mind to mark as answer, but my question was not answered.


    Wednesday, March 15, 2017 9:58 AM