PnP Powershell does not show all the fields in its output.

PrashantV 76 Reputation points
2021-05-14T12:48:51.567+00:00

Its not a question but the discussion. Something I want to share that i recently found regarding PnP Powershell.

Sometime PnP powershell does not show all the fields though you have added those fields to your script. Below can be one of the reason.

I was writing a script to pull information from SharePoint list. For some reason DisplayName field was not showing any output.

Below is the sample script.

$username = "xxxxx@xxxxxxxxxxxxx .onmicrosoft.com"
$password = "xxxx"
$UserCredential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
Connect-PnPOnline -Url "https://xxxx.sharepoint.com/sites/Prashantv" -Credentials $UserCredential

$listItems= Get-PnPListItem -List UserList

foreach($listItem in $listitems){
Write-Host "Employeenumber" : $listItem["Title"]
Write-Host "FirstName" : $listItem["FirstName"]
Write-Host "LastName" : $listItem["LastName"]
Write-Host "DisplayName" : $listItem["DisplayName"]
Write-Host "sam" : $listItem["sam"]
Write-Host "DOJ" : $listItem["DOJ"]
Write-Host "DOB" : $listItem["DOB"]
Write-Host "title" : $listItem["Designation"]
Write-Host "manager" : $listItem["manager"]
Write-Host "Department" : $listItem["Department"]
Write-Host "Team" : $listItem["Team"]
Write-Host "SubTeam" : $listItem["SubTeam"]
Write-Host "Office" : $listItem["Office"]
Write-Host "Co" : $listItem["Co"]
Write-Host "group" : $listItem["group"]
Write-Host "upn" : $listItem["upn"]
Write-Host "company" : $listItem["company"]
Write-Host "---------------------------"
}

I could view all the fields except Displayname. After that i came to know about PnPView. This powershell will not show you output of your script but it will show you properties being used in the list.

See below.
96668-pnppowershell.png

--------------------------------------------------------------------------------------

In above you can properties called "ListViewXML'.

This will provide you fields that are being used by SharePoint in your list. If you see DisplayName parameter is already being used by SharePoint List to capture some other data. Hence It was not showing my own field from the list.

This powershell commandlet will help you to find out such fields being used by List and then you can change the name of your field to get the desired result.

Hope this will help others.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,524 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.