Skip to main content
Edited for dynamically loading of fields
Source Link
Zdeněk Vinduška
  • 2.9k
  • 2
  • 12
  • 24

For working with the values in Field use this code:. Edited for got dynamically List fields and items with all fields. It returning system fields too, but they are empty here. Hope it helps in some way. I am still using classic SPO commands.

Write-Host "Please enter URL of the SharePoint site:"
$url = Read-Host  

Write-Host "Please enter List Name of the SharePoint site:"
$ListName = Read-Host 

Connect-PnPOnline -Url $url -UseWebLogin

$Fields = Get-PnPField -List $ListName   
$global:FieldsList = ""
foreach($Field in $Fields)
{
    $global:FieldsList = $global:FieldsList + $Field.InternalName + ','
}

$Items = (Get-PnPListItem -List $ListName -Fields "Title","StartDate","EndDate"$global:FieldsList).FieldValues
     
foreach($Item in $Items)
{
    Write-Host $Item.Title -ForegroundColor Yellow
    #Hereforeach($Field youin can$Fields)
 list the values or{
 work with them
    $Item Write-Host $Field.StartDateInternalName -ForegroundColor Yellow
    $Item    Write-Host $Item[$Field.EndDateInternalName]
    }
}

For working with the values in Field use this code:

Write-Host "Please enter URL of the SharePoint site:"
$url = Read-Host  

Write-Host "Please enter List Name of the SharePoint site:"
$ListName = Read-Host 

Connect-PnPOnline -Url $url -UseWebLogin
$Items = (Get-PnPListItem -List $ListName -Fields "Title","StartDate","EndDate").FieldValues
 
foreach($Item in $Items)
{
    Write-Host $Item.Title -ForegroundColor Yellow
    #Here you can list the values or work with them
    $Item.StartDate
    $Item.EndDate
}

For working with the values in Field use this code. Edited for got dynamically List fields and items with all fields. It returning system fields too, but they are empty here. Hope it helps in some way. I am still using classic SPO commands.

Write-Host "Please enter URL of the SharePoint site:"
$url = Read-Host  

Write-Host "Please enter List Name of the SharePoint site:"
$ListName = Read-Host 

Connect-PnPOnline -Url $url -UseWebLogin

$Fields = Get-PnPField -List $ListName   
$global:FieldsList = ""
foreach($Field in $Fields)
{
    $global:FieldsList = $global:FieldsList + $Field.InternalName + ','
}

$Items = (Get-PnPListItem -List $ListName -Fields $global:FieldsList).FieldValues    
foreach($Item in $Items)
{
    Write-Host $Item.Title -ForegroundColor Yellow
    foreach($Field in $Fields)
    {
        Write-Host $Field.InternalName -ForegroundColor Yellow
        Write-Host $Item[$Field.InternalName]
    }
}
Source Link
Zdeněk Vinduška
  • 2.9k
  • 2
  • 12
  • 24

For working with the values in Field use this code:

Write-Host "Please enter URL of the SharePoint site:"
$url = Read-Host  

Write-Host "Please enter List Name of the SharePoint site:"
$ListName = Read-Host 

Connect-PnPOnline -Url $url -UseWebLogin
$Items = (Get-PnPListItem -List $ListName -Fields "Title","StartDate","EndDate").FieldValues

foreach($Item in $Items)
{
    Write-Host $Item.Title -ForegroundColor Yellow
    #Here you can list the values or work with them
    $Item.StartDate
    $Item.EndDate
}