Recently, I got a requirement to check if a column exists in a SharePoint list. Instead of manually checking, I used PowerShell. In this tutorial, I will show you how to check if a field exists in a SharePoint Online list using PnP PowerShell. The same script will work for a document library also.
Check If a Field Exists in a SharePoint Online List Using PnP PowerShell
Here, I will show you two methods to check if a field exists in a SharePoint Online list using PowerShell.
Here, I have a created a SharePoint Online list named “EmployeeRecords” and we want to check if a field named “EmployeeID” exists. You can see the list and column like below:

Method 1: Using Get-PnPField
The Get-PnPField cmdlet retrieves fields from a specified SharePoint Online list. You can use it to check if a field exists by attempting to retrieve it by name using this PnP PowerShell cmdlets.
Here is the complete PnP PowerShell script.
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/PowerShellFAQs" -Interactive
$listName = "EmployeeRecords"
$fieldName = "EmployeeID"
try {
$field = Get-PnPField -List $listName -Identity $fieldName
if ($field) {
Write-Output "Field 'EmployeeID' exists in the list 'EmployeeRecords'."
}
} catch {
Write-Output "Field 'EmployeeID' does not exist in the list 'EmployeeRecords'."
}Once you execute the above PowerShell script, you can see it displaying the exact output in the screenshot below. Since the column exists, it displays a message as “Field ‘EmployeeID’ exists in the list ‘EmployeeRecords’.”.

This is one of the best method to check if a field exists in SharePoint Online list using PnP PowerShell.
Check out Get All List Fields in SharePoint Online using PnP PowerShell
Method 2: Using Get-PnPList and Fields Property
Let me show you another method to check if a field exists in SharePoint Online list. I will show you how to use the Get-PnPList cmdlet and Fields Property to check if the field exists in the SharePoint Online list.
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/PowerShellFAQs" -Interactive
$listName = "EmployeeRecords"
$fieldName = "EmployeeID"
# Get the list
$list = Get-PnPList -Identity $listName
# Load the fields collection
$ctx = Get-PnPContext
$ctx.Load($list.Fields)
$ctx.ExecuteQuery()
# Check if the field exists
$fieldExists = $list.Fields | Where-Object { $_.InternalName -eq $fieldName }
if ($fieldExists) {
Write-Output "Field 'EmployeeID' exists in the list 'EmployeeRecords'."
} else {
Write-Output "Field 'EmployeeID' does not exist in the list 'EmployeeRecords'."
}This script retrieves the SharePoint Online list and checks its Fields collection to see if a field with the specified internal name exists. I executed the above PnP PowerShell script and you can see the output in the screenshot below:

Conclusion
Using PnP PowerShell to check if a field exists in a SharePoint Online list can be done efficiently with the Get-PnPField cmdlet or by examining the Fields property of a list. I highly recommend to use the Get-PnPField PnP PowerShell to check if a field exists in a SharePoint Online List.
You may also like the following tutorials:
- Check if a Folder Exists in SharePoint Online using PnP PowerShell
- Download Files from SharePoint Document Library Using PnP PowerShell
- Upload Files to a SharePoint Document Library using PnP PowerShell
- Check if a File Exists in a SharePoint Document Library Using PnP PowerShell
- An error occurred while enumerating through a collection. The collection has not been initialized
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.