Recently, one of my clients wanted to list all the column names from a SharePoint Online list. I tried PnP PowerShell to do it. In this tutorial, I will explain how to get all list fields in SharePoint Online using PnP PowerShell.
I will also show you how to get all the list columns, including out-of-box columns and custom columns, from the SharePoint Online list or document library.
Get All List Fields in SharePoint Online using PnP PowerShell
Here, I have a SharePoint list that has a few columns. You can see the output in the screenshot below:

To get all column names from a specific list in the SharePoint Online site, use the Get-PnPField cmdlet.
$siteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"
Connect-PnPOnline -Url $siteUrl -Interactive
$listName = "Employee Onboarding"
$fields = Get-PnPField -List $listName
foreach ($field in $fields) {
Write-Host "Field Title: $($field.Title) - Internal Name: $($field.InternalName) - Type: $($field.TypeAsString)"
}After you execute the above PowerShell script, you can see the list of columns from the SharePoint Online list. It also includes all the hidden columns, custom columns, and out-of-box columns. Check the screenshot below for your reference.

Get Custom Columns from a SharePoint List using PnP PowerShell
Sometimes, you might just want to get the custom columns from the SharePoint Online list using PnP PowerShell.
Here is the complete PowerShell script.
$siteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"
Connect-PnPOnline -Url $siteUrl -Interactive
$listName = "Employee Onboarding"
$fields = Get-PnPField -List $listName
$customFields = $fields | Where-Object { $_.CanBeDeleted -eq $true }
foreach ($field in $customFields) {
Write-Host "Custom Field Title: $($field.Title) - Internal Name: $($field.InternalName) - Type: $($field.TypeAsString)"
}I executed the above script; you can see the output in the screenshot below. It displays all the custom columns from the SharePoint Online list.

Get Out-of-the-Box Columns from SharePoint List using PnP PowerShell
Now, it is time to show you how to out-of-the-box columns from a SharePoint Online list using PnP PowerShell.
Here is the complete PnP PowerShell.
$siteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"
Connect-PnPOnline -Url $siteUrl -Interactive
$listName = "Employee Onboarding"
$fields = Get-PnPField -List $listName
$ootbFields = $fields | Where-Object { $_.CanBeDeleted -eq $false }
foreach ($field in $ootbFields) {
Write-Host "OOTB Field Title: $($field.Title) - Internal Name: $($field.InternalName) - Type: $($field.TypeAsString)"
}You can see the output in the screenshot below:

Here is the complete script for all the examples above.
$siteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"Connect-PnPOnline -Url $siteUrl -Interactive$listName = "Employee Onboarding"
# Retrieve all fields
$fields = Get-PnPField -List $listName
# Display all fields
Write-Host "All Fields:"
foreach ($field in $fields) {
Write-Host "Field Title: $($field.Title) - Internal Name: $($field.InternalName) - Type: $($field.TypeAsString)"
}
# Retrieve custom fields
$customFields = $fields | Where-Object { $_.CanBeDeleted -eq $true }
Write-Host "`nCustom Fields:"
foreach ($field in $customFields) {
Write-Host "Custom Field Title: $($field.Title) - Internal Name: $($field.InternalName) - Type: $($field.TypeAsString)"
}
# Retrieve out-of-the-box fields
$ootbFields = $fields | Where-Object { $_.CanBeDeleted -eq $false }
Write-Host "`nOOTB Fields:"
foreach ($field in $ootbFields) {
Write-Host "OOTB Field Title: $($field.Title) - Internal Name: $($field.InternalName) - Type: $($field.TypeAsString)"
}Conclusion
In this tutorial, I have explained how to use PnP PowerShell to retrieve all column names from a SharePoint Online list, including custom and out-of-the-box columns.
You may also like the following tutorials:
- Add More Than 5000 Items to a SharePoint Online List using PnP PowerShell
- Import Data from Excel to SharePoint List using PnP PowerShell
- Download Files from SharePoint Document Library Using PnP PowerShell
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.