Yes/No Column PnP PowerShell

PnP PowerShell: Add Lookup Column in SharePoint Online


In the dynamic realm of SharePoint Online, harnessing the power of PnP PowerShell can elevate your site management experience. One of the valuable functionalities it offers is the ability to create Lookup Site Columns effortlessly. In this guide, we’ll walk you through the steps of creating a Lookup Site Column using PnP PowerShell, empowering you to enhance data organization and streamline content relationships within your SharePoint Online environment.

Why Use Lookup Site Columns?

Before diving into the technical aspects, let’s understand the significance of Lookup Site Columns. These columns enable you to establish relationships between lists, enhancing data consistency and facilitating efficient content management. Whether you’re working with projects, clients, or any interconnected data, Lookup Site Columns provide a seamless way to associate information across your SharePoint site.


1. PnP PowerShell Installation

Ensure that you have PnP PowerShell installed. To setup the PnP PowerShell Module, you can follow another blog post written by me at PnP PowerShell: How to get started? – Hemant Kabra

2. Connect to SharePoint Online

Connect to your SharePoint Online environment using:

Connect-PnPOnline -Url -Interactive

Creating a Lookup Site Column

Now, let’s dive into the step-by-step process of creating a Lookup Site Column using PnP PowerShell.

1. Identify Target Lists

Determine the source and destination lists. The Lookup Column will reference values from the source list and display them in the destination list.

2. Retrieve List Information

Obtain the necessary details about the source and destination lists. Use commands like Get-PnPTenantSite and Get-PnPList to fetch list information.

3. Create Lookup Column

Now that you’re already connected to your SharePoint Online site, you can create a Lookup site column using the Add-PnPField cmdlet. Use the following code to create a Lookup Site Column:

$sourceListID = "SourceListWebId" ## ID of the source list
$sourceFieldName = "Title" ## Name of the lookup column

$ctx = Get-PnPContext

$lookupField = Add-PnPField -List "DestinationList" -DisplayName "ProjectLookup" -InternalName "ProjectLookup" -Type Lookup -AddToDefaultView 

$lookupField = $lookupField.TypedObject
$lookupField.LookupList = $sourceListID
$lookupField.LookupField = $sourceFieldName

Replace “DestinationList,” “ProjectLookup,” and “SourceListWebId” with your actual values.

4. Verification

Confirm the creation of the Lookup Site Column using SharePoint Online. Navigate to the destination list’s settings, and you should see the newly added column.


Congratulations! You’ve successfully created a Lookup Site Column using PnP PowerShell in SharePoint Online. By leveraging this powerful capability, you can enhance the relational structure of your data, fostering a more organized and efficient SharePoint environment. Stay tuned for more insights into optimizing your SharePoint experience with PnP PowerShell.

Happy scripting!

Related Posts

Leave a Reply

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