Add Lookup Field to SharePoint List using PowerShell

Requirement: PowerShell script to add lookup field to SharePoint list:

Scenario: You have a parent list called “Parent Projects” and a child list called “Project Milestones”. The “Parent Project Name” field in the child list is being looked up from the parent list’s “Project Name” field.

sharepoint powershell add lookup column to list

PowerShell to Add Lookup Field to SharePoint List

Use this PowerShell script to add a lookup column to the SharePoint list:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 

#configuration parameters
$ParentListName="Parent Projects"
$ChildListName="Project Milestones"

$ParentLookupColumnName="Project Name"
$ChildLookupColumnName="Parent Project Name"

#Get the Parent and Child Lists
$Web = Get-SPWeb $WebURL
$ParentList = $web.Lists[$ParentListName]
$ChildList = $web.Lists[$ChildListName]

#Check if Field exists already
    #sharepoint powershell - create lookup field
    $ChildLookupColumn = $ChildList.Fields.AddLookup($ChildLookupColumnName,$,$False)
    $ChildLookupColumn = $ChildList.Fields[$ChildLookupColumnName]

    #Setup lookup Field property
    $ChildLookupColumn.LookupField = $ParentList.Fields[$ParentLookupColumnName]
    write-host "Lookup field added successfully!" -f green
    write-host "Field Exists already!" -f red

That’s all! We’ve created a lookup column using PowerShell in the SharePoint list. To add a lookup column in the SharePoint Online list, use: How to create a lookup column in the SharePoint Online list using PowerShell?

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “Add Lookup Field to SharePoint List using PowerShell

  • Hello,
    Could you please tell how can we can add the additional lookup fields.

  • Can I Add Additional Lookup Field?

  • how to create sharepoint list view using powershell from content type column


Leave a Reply

Your email address will not be published. Required fields are marked *