Setting a SharePoint Multi-value Lookup Field value using PowerShell and CSOM


In this super short post I’ll show how to use Powershell and CSOM (Client-side Object Model) to set the value of a multi-value Lookup field column in a list or library.

To set the value for a single-value column you just need to set the column value to a FieldLookupValue instance, note that only the LookupId property can be set, so you have to know/get what the list item ID of the target lookup item is.

For a multi-value column, you have to supply a FieldLookupValue[] array ~ in C# this is easy enough, but in Powershell it’s not obvious how to do it.

The trick is to create a vanilla Object[] array and add FieldLookupValue instance to it, then to convert that to an FieldLookupValue[] array, and use that as the item column value.

Here’s the code;

Published by

Phil Harding

SharePoint Consultant, Developer, Father, Husband and Climber.

4 thoughts on “Setting a SharePoint Multi-value Lookup Field value using PowerShell and CSOM

  1. This is just what i’m looking for…..please can you repost the code Phil.

  2. Thanks Phil, It wasn’t showing. Different browser and yes I can see it now.. thanks Howard

  3. Excellent job Phil; I now have the multi value update working. However I’m now getting errors when updating a single value lookup field. The exception is “Value does not fall within the expected range”. This is my code ;-

    $lookupValue = New-Object Microsoft.SharePoint.Client.FieldLookupValue

    $lookupValue.LookupId = GetLookupFieldIDs -lookupField “Title” -lookupValues “$($Vendor.Text)” -lookupSourceList “$strSharePointVendorList”

    $item[“ApplicationVendor0”] = $lookupValue

    GetLookupFieldIDs is a function that just returns an integer of the list item ID that I want to use.

    Any ideas why this isn’t working? lookupvalue seems to be cast correctly and only the LookupId is populated.

    LookupId LookupValue TypeId
    ——– ———– ——
    428 {f1d34cc0-9b50-4a78-be…

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