1

I get all my sites via:

$pages = Get-PnPListItem -List Sites

I use the variable and get to every site in a foreach-loop:

foreach($page in $pages)
  {
Write-Host "Page" $page.FieldValues["FileLeafRef"] "..."

 }

Above will print out the name for every page. Let say that the page come from a library/list that have the column "category". How can I access the value from that column in the foreach-loop?

1

as below your prpoerty should be as $($myData) in your string

Write-Host "Page '$($page.FieldValues["FileLeafRef"])' '$($page.FieldValues["category"])'   "
1

try below code, Id 47 is the Item Id in the library

Connect-PnPOnline –Url https://tenant.sharepoint.com/sites/dev –Credentials (Get-Credential)
$item = Get-PnPListItem -List "Site Pages" -Id 47

$Fields = Get-PnPField -List "Site Pages"

foreach($Field in $Fields)
 {
        Write-Host $Field.InternalName -ForegroundColor Yellow
        Write-Host $item[$Field.InternalName]
  }

Source

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.