Powershell: Empty FieldValue Array when reading a SharePoint Online List items that do exist

%3CLINGO-SUB%20id%3D%22lingo-sub-1449434%22%20slang%3D%22en-US%22%3EPowershell%3A%20Empty%20FieldValue%20Array%20when%20reading%20a%20SharePoint%20Online%20List%20items%20that%20do%20exist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1449434%22%20slang%3D%22en-US%22%3E%3CP%3EHere%20is%20my%20present%20Powershell%20Code.%20Though%20there%20are%20values%20in%20the%20FieldUserValue%5B%5D%20array%2C%20it%20reads%20as%20empty%20here%2C%20and%20that%20is%20the%20problem.%20A%20representation%20of%20the%20actual%20HTML%20list%20is%20below%20the%20code.%3C%2FP%3E%3CP%3EIf%20((%5BMicrosoft.SharePoint.Client.FieldUserValue%5B%5D%5D%24ListItems%5B%22Visit_x0020_Attendees%22%5D).Count%20-gt%200)%20%7B%20%24FieldValues%20%3D%20%5BMicrosoft.SharePoint.Client.FieldUserValue%5B%5D%5D%24ListItems%5B%22Visit_x0020_Attendees%22%5D%20Write-Host%20-f%20Red%20%22FieldValues%20Count%22%2C%20%24FieldValues.Count%20ForEach(%24FieldValue%20in%20%24FieldValues)%20%7B%20Write-Host%20-f%20Yellow%20%24FieldValue.LookupValue%20%3A%20%24FieldValue.Email%20%24ExportItem%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20%22Visit%20Attendees%22%20-value%20%24FieldValue.LookupValue%20%7D%20%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24ExportItem%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20%22Visit%20Attendees%22%20-value%20%24_%5B%22Visit_x0020_Attendees%22%5D.LookupValue%20-%20yields%20System.Object%5B%5D%20when%20there%20are%20multiple%20names.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24ExportItem%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20%22Visit%20Attendees%22%20-value%20%24_%5B%22Visit_x0020_Attendees%22%5D%20-%20yields%20Microsoft.SharePoint.Client.FieldUserValue%5B%5D%20(no%20.LookupValue)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHTML%20of%20the%20SharePoint%20list%20item%20array.%26nbsp%3B%3C%2FP%3E%3CP%3E%22Visit_x0020_Attendees%22%3A%20%5B%7B%22id%22%3A%2259%22%2C%22value%22%3A%22Pam%20Tooler%22%2C%22title%22%3A%22Pam%20Tooler%22%2C%22email%22%3A%22PTooler%40xyz.com%22%2C%22sip%22%3A%22PTooler%40xyz.com%22%2C%22picture%22%3A%22%22%2C%22jobTitle%22%3A%22Fiscal%20Manager%22%2C%22department%22%3A%22Elections%22%7D%2C%7B%22id%22%3A%22153%22%2C%22value%22%3A%22Loretta%20Lynn%22%2C%22title%22%3A%22Loretta%20Lynn%22%2C%22email%22%3A%22LLynn%40xyz.com%22%2C%22sip%22%3A%22LLynn%40xyz.com%22%2C%22picture%22%3A%22https%3A%5Cu002f%5Cu002fxyz.com-my.sharepoint.com%3A443%5Cu002fUser%2520Photos%5Cu002fProfile%2520Pictures%5Cu002flg_MThumb.jpg%22%2C%22jobTitle%22%3A%22Election%20Manager%22%2C%22department%22%3A%22Elections%22%7D%2C%7B%22id%22%3A%22154%22%2C%22value%22%3A%22Don%20Chapman%22%2C%22title%22%3A%22Don%20Chapman%22%2C%22email%22%3A%22DChapman%40xyz.com%22%2C%22sip%22%3A%22DChapman%40xyz.com%22%2C%22picture%22%3A%22%22%2C%22jobTitle%22%3A%22Chief%20Deputy%22%2C%22department%22%3A%22Clerk%22%7D%5D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1449434%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

Here is my present Powershell Code. Though there are values in the FieldUserValue[] array, it reads as empty here, and that is the problem. A representation of the actual HTML list is below the code.

If (([Microsoft.SharePoint.Client.FieldUserValue[]]$ListItems["Visit_x0020_Attendees"]).Count -gt 0) { $FieldValues = [Microsoft.SharePoint.Client.FieldUserValue[]]$ListItems["Visit_x0020_Attendees"] Write-Host -f Red "FieldValues Count", $FieldValues.Count ForEach($FieldValue in $FieldValues) { Write-Host -f Yellow $FieldValue.LookupValue : $FieldValue.Email $ExportItem | Add-Member -MemberType NoteProperty -Name "Visit Attendees" -value $FieldValue.LookupValue } }

 

$ExportItem | Add-Member -MemberType NoteProperty -Name "Visit Attendees" -value $_["Visit_x0020_Attendees"].LookupValue - yields System.Object[] when there are multiple names.

 

$ExportItem | Add-Member -MemberType NoteProperty -Name "Visit Attendees" -value $_["Visit_x0020_Attendees"] - yields Microsoft.SharePoint.Client.FieldUserValue[] (no .LookupValue)

 

HTML of the SharePoint list item array. 

"Visit_x0020_Attendees": [{"id":"59","value":"Pam Tooler","title":"Pam Tooler","email":"PTooler@xyz.com","sip":"PTooler@xyz.com","picture":"","jobTitle":"Fiscal Manager","department":"Elections"},{"id":"153","value":"Loretta Lynn","title":"Loretta Lynn","email":"LLynn@xyz.com","sip":"LLynn@xyz.com","picture":"https:\u002f\u002fxyz.com-my.sharepoint.com:443\u002fUser%20Photos\u002fProfile%20Pictures\u002flg_MThumb.jpg","jobTitle":"Election Manager","department":"Elections"},{"id":"154","value":"Don Chapman","title":"Don Chapman","email":"DChapman@xyz.com","sip":"DChapman@xyz.com","picture":"","jobTitle":"Chief Deputy","department":"Clerk"}]

0 Replies