Forum Discussion
fodelement
Apr 24, 2020Copper Contributor
SharePoint PnP Author column with PowerShell
Hello all, I have done a lot of reading and can't seem to find the answer. I am working on my first PnP script to pull all the data from a SharePoint site and save it into an CSV file. So far everyt...
WSUHoey
May 21, 2021Copper Contributor
I was able to get Microsoft.SharePoint.Client.FieldUserValue to return using the below function
(written by Justin W Grote, provided via the PowerShell Discord):
# provided by @justinwgrote, PowerShell Discord
function ExpandSharepointLookupValue ($Value) {
if ($Value -is [Microsoft.SharePoint.Client.FieldLookupValue]) {
$Value[0].LookupValue
} else {
$Value
}
}
I then adjusted the Add-Member call in the loop to this:
$obj | Add-Member -MemberType NoteProperty -Name $_.Key -Value (ExpandSharepointLookupValue($_.Value))