0

Is there an easy way to get all list elements that have the same value in a column?

Let's say I have a list with a column called system.

Is there a possibility to get all items with the value "Windows" in the system column?

I could not find any parameter of Get-PnPListItem that could fit.

0

You can use -Query parameter to filter the list items by using CAML Query.

Reference: Get-PnPListItem Examples - Check Example 5.

Try Something like below:

$listItems = Get-PnPListItem -List YOURLISNAME -Query "<View><Query><Where><Eq><FieldRef Name='System'/><Value Type='Text'>Windows</Value></Eq></Where></Query></View>"
  • That worked! Thank you so much. – Jenew Sep 13 at 8:20
  • I have tried this command: $listItems = Get-PnPListItem -List ImportTest -Query "<View><Query><Where><Eq><FieldRef Name='itSystem'/><Value Type='Text'>EDM Cosima</Value></Eq></Where></Query></View>" -Fields "name","system","admin", "read","write" Now it says that the parameter set cannot be resolved. Does that mean I can't use the Query and Fields parameter together? – Jenew Sep 13 at 8:28
  • I am not a PowerShell expert.But you can try using ViewFields like $listItems= Get-PnPListItem -List YOURLISNAME -Query "<View><ViewFields><FieldRef Name="ID" /><FieldRef Name="Title" /><FieldRef Name="Name" /></ViewFields><Query><Where><Eq><FieldRef Name='System'/><Value Type='Text'>Windows</Value></Eq></Where></Query></View>". Use internal names of field in Query. – Ganesh Sanap Sep 13 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.