2

How to get the column values of the items in a Sharepoint online document library using Powershell PNP? If all the document would have been in the root folder in the library, this works great.

Connect-PnPOnline –Url https://<company>.sharepoint.com/sites/<Site> –Credentials (Get-Credential)
$Item = Get-PnPListItem -List "SampleList" -Fields "Id","TestColumn"
$Item.FieldValues.TestColumn

However, I need to query the items in a subfolder that exists in "SampleList". And that seems to be harder.

Accodring to the documentation I can use -FolderServerRelativeUrl,

Get-PnPListItem -FolderServerRelativeUrl "/sites/<Site>/Lists/SampleList/Folder1"

But it cannot find the parameter -FolderServerRelativeUrl....

Get-PnPFolderItem : A parameter cannot be found that matches parameter name 'FolderServerRelativeUrl'

Any ideas of other cmdlets I can use?

2 Answers 2

2

I soon realized that Get-PnPListItem returns all items, including folders and subfolders :) So I ended up using a Where-Object to filter the items instead.

$Item = Get-PnPListItem -List "SampleList" -Fields "Id","TestColumn" | Where-Object {$_.FieldValues.FileRef -like "*Folder1*"}
Sign up to request clarification or add additional context in comments.

Comments

0

I am able to call the mentioned cmdlet:

Get-PnPListItem -List Samples -FolderServerRelativeUrl "/sites/contosomarketing/Lists/Samples/Demo"

I tested it on my SP online environment:

Test:

enter image description here

So I suggest you have a check the value of 'FolderServerRelativeUrl' then have a try again.

BR

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.