Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phillipharding/7267ef81bbf9efc47de9 to your computer and use it in GitHub Desktop.
Save phillipharding/7267ef81bbf9efc47de9 to your computer and use it in GitHub Desktop.
<#
get $ctx and $site
#>
$web = $site.OpenWeb("news")
$list = $web.Lists.GetByTitle("Posts")
$item = $list.GetItemById(6)
$ctx.Load($web)
$ctx.Load($list)
$ctx.Load($item)
$ctx.ExecuteQuery()
$mvLookup = $item["MultiValueLookupColumnName"]
$mvLookup |% { "Lookup Value: $($_.LookupId):$($_.LookupValue)" }
# create an Object[] and add FieldLookupValue instances
$lookupValueCollection = @()
$lookupValue = New-Object Microsoft.SharePoint.Client.FieldLookupValue
$lookupValue.LookupId = 4
$lookupValueCollection += $lookupValue
$lookupValue = New-Object Microsoft.SharePoint.Client.FieldLookupValue
$lookupValue.LookupId = 5
$lookupValueCollection += $lookupValue
# convert the Object[] to a FieldLookupValue[]
$mvLookup = [Microsoft.SharePoint.Client.FieldLookupValue[]]$lookupValueCollection
# set multi-value lookup field value
$item["MultiValueLookupColumnName"] = $mvLookup
$item.Update()
$ctx.ExecuteQuery()
@mikwis
Copy link

mikwis commented Oct 9, 2018

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment