I am trying to use PnP with CAML Query to retrieve all items in a document library where certain fields meet certain values. The query filter is working fine, it retrieves the correct documents, however I can't seem to get the ViewFields working. All it ever shows me no matter what is the Id, Title, GUID.

$listItems = Get-PnPListItem -List Documents -Query "<view><query>
  <FieldRef Name='MyChoice' />
  <FieldRef Name='FileRef' />
  <FieldRef Name='FileLeafRef' />
  <ViewAttributes Scope='RecursiveAll' />
  <Lists ServerTemplate='101' />
              <FieldRef Name='MyChoice' />
              <Value Type='MultiChoice'>Text Two</Value>
              <FieldRef Name='MySecurity' />
              <Value Type='MultiChoice'>Internal</Value>

What am I doing wrong??

  • Tested and working with this query $Query = "<View Scope='RecursiveAll'><RowLimit>300</RowLimit> <ViewFields><FieldRef Name='Title'/><FieldRef Name='URL'/></ViewFields> <Query><Where><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>Process Link</Value></Eq></Where></Query></View>" #get all list items using powershell sharepoint online - matching given query $ListItems = Get-PnPListItem -List $ListName -Query $Query
    – Anuja
    Nov 2, 2020 at 0:09

1 Answer 1


When you are looking at the results you get back from Get-PnPListItem, if you do this:

$listItems | ForEach-Object {
$_ | Format-Table;

Then it will only show you id, Title and GUID. However, if you do this:

$listItems | ForEach-Object {
$_.FieldValues | Format-Table;

You will see that all of the requested field values are actually being returned. So in your case


should return

Text Two

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .