Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

How to Update a Lookup Field Using PnP PowerShell in SharePoint Online

You run Set-PnPListItem with the office name, and PowerShell answers that the input string isn’t in a correct format. Lookup columns don’t want the text you see in the list; they want the ID of an item in another list.

In this tutorial, we’ll show you how to update lookup field using PnP PowerShell in SharePoint Online: single and multi-value lookups, finding an ID from a title, clearing the value, reading it back and bulk updates from a CSV file. Every result comes from our own test list.

Quick answer: Pass the ID of the item in the source list, not its title: Set-PnPListItem -List "SPGDemo Equipment" -Identity 1 -Values @{ Location = 3 }. For a multi-value lookup, pass an array of IDs such as @{ Vendors = 3, 5 }, and use $null to clear it.

Set-PnPListItem -List "SPGDemo Equipment" -Identity 1 -Values @{ Location = 3 }

What You Need Before You Start

  • PowerShell 7.4 or later with PnP.PowerShell 3.x and your own Entra ID app registration. We walk through the sign-in in connecting to SharePoint Online with PowerShell.
  • Edit permission on the list you’re updating and read permission on the source list behind the lookup.
  • The internal names of your lookup columns. -Values ignores display names.

We tested everything with PnP.PowerShell 3.3.0 against /sites/SPGuides, connected like this:

Connect-PnPOnline -Url "https://spguides.sharepoint.com/sites/SPGuides" `
    -ClientId "<your-app-client-id>" -Interactive

Step 1: Create the Lookup Columns (Skip If You Have Them)

Our demo list, SPGDemo Equipment, tracks 25 laptops, docks and phones. We added two source lists, SPGDemo Locations and SPGDemo Equipment Vendors, plus a single lookup Location and a multi-value lookup Vendors. Add-PnPField has no parameter for the source list, so we used Add-PnPFieldFromXml. For other column settings, see customizing SharePoint list fields with PnP PowerShell.

# Parent lists that the lookup columns point to
$locations = New-PnPList -Title "SPGDemo Locations" -Template GenericList
"New York Office", "Chicago Office", "Dallas Office", "Seattle Office", "Atlanta Office" |
    ForEach-Object { Add-PnPListItem -List $locations -Values @{ Title = $_ } | Out-Null }

$vendors = New-PnPList -Title "SPGDemo Equipment Vendors" -Template GenericList
"Dell Technologies", "Lenovo", "Microsoft", "HP Inc.", "CDW", "Insight" |
    ForEach-Object { Add-PnPListItem -List $vendors -Values @{ Title = $_ } | Out-Null }

# Single and multi-value lookup columns on the child list
$single = "<Field Type='Lookup' DisplayName='Location' Name='Location' List='{$($locations.Id)}' ShowField='Title' />"
$multi  = "<Field Type='LookupMulti' DisplayName='Vendors' Name='Vendors' List='{$($vendors.Id)}' ShowField='Title' Mult='TRUE' />"
Add-PnPFieldFromXml -List "SPGDemo Equipment" -FieldXml $single | Out-Null
Add-PnPFieldFromXml -List "SPGDemo Equipment" -FieldXml $multi  | Out-Null

Get-PnPField -List "SPGDemo Equipment" |
    Where-Object InternalName -in "Location", "Vendors" |
    Select-Object Title, InternalName, TypeAsString, LookupField, AllowMultipleValues |
    Format-Table -AutoSize
PnP PowerShell creating a single Lookup and a LookupMulti column on a SharePoint list with Add-PnPFieldFromXml

Step 2: Update a Single Lookup Field by Item ID

A lookup column stores the ID of the source item. Dallas Office is item 3 in SPGDemo Locations, so we pass 3. It’s the same Set-PnPListItem call from our PnP PowerShell CRUD guide for list items:

# Set the single lookup "Location" on item 1 to ID 3 (Dallas Office in SPGDemo Locations)
Set-PnPListItem -List "SPGDemo Equipment" -Identity 1 -Values @{ Location = 3 } | Out-Null

# Read it back
$item = Get-PnPListItem -List "SPGDemo Equipment" -Id 1 -Fields Title, Location
$loc  = $item["Location"]
"Item:        $($item['Title'])"
"LookupId:    $($loc.LookupId)"
"LookupValue: $($loc.LookupValue)"
"Type:        $($loc.GetType().Name)"
Set-PnPListItem updating a SharePoint single lookup field by ID and reading back LookupId and LookupValue

The value comes back as a FieldLookupValue object: LookupId is 3 and LookupValue is the title SharePoint shows in the list.

Step 3: Update a Multi-Value Lookup Field

For a multi-value lookup, pass an array of IDs. The string form "3,5" worked for us too. Setting the field replaces every value, so to add one vendor we read the current IDs first and append the new one.

# Multi-value lookup "Vendors": pass an array of IDs (3 = Microsoft, 5 = CDW)
Set-PnPListItem -List "SPGDemo Equipment" -Identity 5 -Values @{ Vendors = 3, 5 } | Out-Null

# Add a third vendor (6 = Insight) without dropping the existing ones
$item = Get-PnPListItem -List "SPGDemo Equipment" -Id 5 -Fields Vendors
$ids  = @($item["Vendors"].LookupId) + 6 | Select-Object -Unique
Set-PnPListItem -List "SPGDemo Equipment" -Identity 5 -Values @{ Vendors = $ids } | Out-Null

$item = Get-PnPListItem -List "SPGDemo Equipment" -Id 5 -Fields Title, Vendors
"Item: $($item['Title'])"
$item["Vendors"] | Select-Object LookupId, LookupValue | Format-Table -AutoSize
PnP PowerShell setting a multi-value lookup column with an array of IDs and appending a third value

Surface Laptop 7 now lists Microsoft, CDW and Insight; the first two survived the second update.

Step 4: Find the Lookup ID by Title

Nobody remembers that Chicago Office is ID 2, so we look it up. A CAML query asks SharePoint to filter on the server, which scales to large source lists. If CAML is new to you, our CAML query builder guide explains the syntax.

# Find the lookup ID from the title with a CAML query
$title = "Chicago Office"
$caml  = "<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>$title</Value></Eq></Where></Query></View>"
$match = Get-PnPListItem -List "SPGDemo Locations" -Query $caml
if (-not $match) { throw "No location named '$title'" }
"'$title' has ID $($match.Id)"

Set-PnPListItem -List "SPGDemo Equipment" -Identity 3 -Values @{ Location = $match.Id } | Out-Null

$item = Get-PnPListItem -List "SPGDemo Equipment" -Id 3 -Fields Title, Location
"$($item['Title']) -> $($item['Location'].LookupValue) (ID $($item['Location'].LookupId))"
Get-PnPListItem with a CAML query finding a lookup ID by title before updating the lookup field

For a source list with a few hundred items, filtering on the client is shorter and just as reliable:

$id = (Get-PnPListItem -List "SPGDemo Locations" -Fields Title |
    Where-Object { $_["Title"] -eq "Seattle Office" }).Id

Step 5: Bulk Update Lookup Fields from a CSV File

CSV files from other teams contain titles, not IDs. Our file has an ItemID column, a location name and vendor names separated by semicolons. Row 18 holds a location that doesn’t exist yet:

ItemID,Location,Vendors
2,Dallas Office,Dell Technologies;CDW
4,Dallas Office,Dell Technologies
6,Chicago Office,Insight
9,Seattle Office,HP Inc.;CDW
18,Denver Office,Dell Technologies

We read each source list once into a title-to-ID hashtable, skip rows that don’t match, and queue the updates in one batch. For thousands of rows, see handling 5,000+ items with PnP PowerShell batches.

$csv = Import-Csv -Path "C:\SPGuidesDemo\equipment-lookups.csv"

# Title -> ID maps: one read per parent list
$locId = @{}
Get-PnPListItem -List "SPGDemo Locations" -Fields Title | ForEach-Object { $locId[$_["Title"]] = $_.Id }
$venId = @{}
Get-PnPListItem -List "SPGDemo Equipment Vendors" -Fields Title | ForEach-Object { $venId[$_["Title"]] = $_.Id }

$batch = New-PnPBatch
$queued = 0
foreach ($row in $csv) {
    if (-not $locId.ContainsKey($row.Location)) {
        Write-Warning "Item $($row.ItemID): no location '$($row.Location)'"; continue
    }
    $vendorIds = foreach ($v in $row.Vendors -split ";") {
        if ($venId.ContainsKey($v.Trim())) { $venId[$v.Trim()] }
        else { Write-Warning "Item $($row.ItemID): no vendor '$v'" }
    }
    Set-PnPListItem -List "SPGDemo Equipment" -Identity ([int]$row.ItemID) -Batch $batch `
        -Values @{ Location = $locId[$row.Location]; Vendors = @($vendorIds) }
    $queued++
}
Invoke-PnPBatch -Batch $batch
"Updated $queued of $($csv.Count) items"
PnP PowerShell bulk updating SharePoint lookup fields from a CSV file with a title to ID map and New-PnPBatch

Nine rows went through in one batch and Denver Office was reported instead of failing the run. If your data lives in a workbook, reading Excel into a SharePoint list shows how to load it first.

Step 6: Read the Lookup Value Back

Always check the result. A multi-value lookup returns an array of FieldLookupValue objects, so join them for a readable table:

# Read lookup values back: FieldLookupValue has LookupId and LookupValue
Get-PnPListItem -List "SPGDemo Equipment" -Fields Title, Location, Vendors -PageSize 500 |
    Where-Object { $_["Location"] } |
    Select-Object Id,
        @{ n = "Title";    e = { $_["Title"] } },
        @{ n = "Location"; e = { $_["Location"].LookupValue } },
        @{ n = "Vendors";  e = { $_["Vendors"].LookupValue -join ", " } },
        @{ n = "VendorIds"; e = { $_["Vendors"].LookupId -join "," } } |
    Format-Table -AutoSize
Get-PnPListItem reading SharePoint lookup field values with LookupId and LookupValue for single and multi-value lookups

Item 18 has no location, which matches the CSV warning. For reusable versions, see our PnP PowerShell scripts for SharePoint.

Step 7: Clear a Lookup Field

To empty a lookup, set it to $null. The same works for single and multi-value columns:

# Clear both lookups on item 25: pass $null
$values = @{ Location = $null; Vendors = $null }
Set-PnPListItem -List "SPGDemo Equipment" -Identity 25 -Values $values | Out-Null

$item = Get-PnPListItem -List "SPGDemo Equipment" -Id 25 -Fields Title, Location, Vendors
"Item:     " + $item["Title"]
"Location: " + $(if ($item["Location"]) { $item["Location"].LookupValue } else { "(empty)" })
"Vendors:  " + $(if ($item["Vendors"]) { $item["Vendors"].LookupValue -join ", " } else { "(empty)" })
Set-PnPListItem clearing a SharePoint lookup field and a multi-value lookup by passing null

Lookup Value Cheat Sheet

Task-Values entryWhat we saw
Set a single lookup@{ Location = 3 }LookupId 3, LookupValue Dallas Office
Set a multi-value lookup@{ Vendors = 3, 5 } or "3,5"Both forms saved IDs 3 and 5
Add to a multi-value lookupRead .LookupId, append, set the arrayExisting values kept
Clear@{ Location = $null }Field empty
Title instead of ID@{ Location = "Chicago Office" }Format error, nothing saved
ID that doesn’t exist@{ Location = 99 }Saved silently with an empty value

Common Mistakes to Avoid

We reproduced the three mistakes we see most on item 7:

$list  = "SPGDemo Equipment"
$tests = [ordered]@{
    "ID that doesn't exist"   = @{ Location = 99 }
    "Title instead of ID"     = @{ Location = "Chicago Office" }
    "Not the internal name"   = @{ "Office Location" = 2 }
}
foreach ($test in $tests.GetEnumerator()) {
    try {
        $null = Set-PnPListItem -List $list -Identity 7 -Values $test.Value -ErrorAction Stop
        "{0,-22} -> accepted" -f $test.Key
    }
    catch { "{0,-22} -> {1}" -f $test.Key, $_.Exception.Message }
}

$loc = (Get-PnPListItem -List $list -Id 7 -Fields Location)["Location"]
"Item 7 now: LookupId = $($loc.LookupId), LookupValue = '$($loc.LookupValue)'"
PnP PowerShell lookup field errors: wrong ID accepted, title instead of ID and a column that is not the internal name
  • Wrong ID: SharePoint accepted ID 99 without an error and stored a lookup that points nowhere. Validate IDs against the source list, as the CSV script does.
  • Title instead of ID: “The input string ‘Chicago Office’ was not in a correct format.” Look up the ID first.
  • Display name instead of internal name: “Field Office Location not present in list.” Find the real name with getting column internal names with PnP.
  • Too many lookups in one query: Get-PnPListItem returns at most 12 lookup-type columns (lookup, person, managed metadata, Created By, Modified By) per query. Use -Fields or -Id when a list has more.

Can You Update a Lookup Without Changing Modified?

Yes. Add -UpdateType SystemUpdate. When we set item 7’s location this way, Modified and the version number (8.0) didn’t change. It also doesn’t trigger Power Automate flows, which helps during data cleanup. Our guide to adding list items with PowerShell covers new items instead.

Set-PnPListItem -List "SPGDemo Equipment" -Identity 7 -Values @{ Location = 4 } -UpdateType SystemUpdate

Next Steps

Once your lookups are filled, try the same pattern from a scheduled script, or build the list itself with creating a SharePoint list and columns with PnP PowerShell so the lookup columns exist from day one.

We use these guides alongside lookup updates in our own tenant:

Frequently Asked Questions

How do I update a lookup field using PnP PowerShell?

Run Set-PnPListItem with -Values and the internal column name mapped to the ID of the source item, for example @{ Location = 3 }. The Set-PnPListItem reference lists the accepted formats.

How do I set a multi-value lookup column with PowerShell?

Pass an array of IDs, such as @{ Vendors = 3, 5 }, or the string “3,5”. Setting the column replaces all values, so read the current LookupId values first if you only want to add one.

Can I set a lookup field by its title instead of the ID?

Not directly. Set-PnPListItem returns a format error for a title. Find the ID with Get-PnPListItem and a CAML query or Where-Object, then pass that ID.

How do I clear a lookup column in SharePoint with PnP PowerShell?

Set the column to $null, for example @{ Location = $null; Vendors = $null }. It works for single and multi-value lookups.

Why does Get-PnPListItem not return my lookup column?

SharePoint returns at most 12 lookup-type columns per query when you don’t pick fields. Use -Fields or -Id, as the Get-PnPListItem reference explains.