Get-PnPListItem -Fields parameter not working as documented.
If I select the -Fields parameter with a list of fields to be displayed, then I would expect to see those fields displayed.
PS C:\Program Files\Common Files\microsoft shared\Web Server Extensions15\CONFI
G\POWERSHELL\Registration> Get-PnPListItem -List "Access Requests" -Fields "Tit
le", "ModerationInformation"
Id Title Unique Id
-- ----- ---------
1 By steve for steve.
2 By steve for Chris.
3 By Administrator for Administrator.
PS C:\Program Files\Common Files\microsoft shared\Web Server Extensions15\CONFI
G\POWERSHELL\Registration> Get-PnPListItem -List "Access Requests" -Fields \"Ti
tle\", \"ModerationInformation\"
Id Title Unique Id
-- ----- ---------
1
2
3
see screenshots above
PS C:\Program Files\Common Files\microsoft shared\Web Server Extensions15\CONF
G\POWERSHELL\Registration> Get-Module -Name pnppowershell -ListAvailable
Directory:
C:\Users\pricen\AppData\Local\Apps\SharePointPnPPowerShell2013\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.9.1611.0 SharePointPnPPowerShell2013 {Get-PnPTimeZoneId...
Hi Nigel,
Actually the cmdlet does not state that it will _display_ the fields, it just states that it will retrieve the fields. The way CSOM works, for performance reasons, is that it will only retrieve those properties that have explicitly been requested. This will make the payload that will come down from the server smaller, and the server has to do less too. Resulting in more efficient processing and less SQL queries against content database. What the Field parameter does in the cmdlet is only -retrieve- those fields that you are interested in. However, due to the way output works of objects in PowerShell, it will not be able to actually -render- those fields in the list. You can however, write some code in PowerShell that lists those fields if you want to. Taking your initial cmdlet call above:
$items = Get-PnPListItem -List "Access Requests" -Fields Title,ModerationInformation
$items | %{new-object PSObject -Property @{Title=$_["Title"];ModerationInformation=$_["ModerationInformation"]}}
| select Title,ModerationInformation
Most helpful comment
Hi Nigel,
Actually the cmdlet does not state that it will _display_ the fields, it just states that it will retrieve the fields. The way CSOM works, for performance reasons, is that it will only retrieve those properties that have explicitly been requested. This will make the payload that will come down from the server smaller, and the server has to do less too. Resulting in more efficient processing and less SQL queries against content database. What the Field parameter does in the cmdlet is only -retrieve- those fields that you are interested in. However, due to the way output works of objects in PowerShell, it will not be able to actually -render- those fields in the list. You can however, write some code in PowerShell that lists those fields if you want to. Taking your initial cmdlet call above: