I'm new with PnPPowershell and trying to work with some data in columns. I'm trying to understand the values in user -- both single and multi user columns. I have this code (all the variables used are defined earlier if not shown, and the code does work.) and it outputs the following
$FieldNames = "ID","Title","SinglePerson","MultiPerson"
$listItems = (Get-PnPListItem -List $ListName -Fields $FieldNames -PageSize 1000).FieldValues
$listItems | ForEach-Object {
$_.GetEnumerator() | Where-Object { $_.Key -IN $FieldNames } | ForEach-Object {
Write-Host $_.Key $_.Value
}
}
ID 2
Title Single and multi
SinglePerson Microsoft.SharePoint.Client.FieldUserValue
MultiPerson Microsoft.SharePoint.Client.FieldUserValue Microsoft.SharePoint.Client.FieldUserValue Microsoft.SharePoint.Client.FieldUserValue
I found this documentation which says that there is an Email property. So I can get the email(s) by using $_.Value.Email
. But I need to know that it is a person column and not a text or other type of column.
How can I get the value of the SinglePerson and MultiPerson columns? When iterating over all the columns how can I know if I have a single person or multi person column?
This is just a test for learning and eventually I need to iterate over thousands of list items with about 50 columns of various types.