【问题标题】:Powershell Read Sharepoint List Item of Type FieldUserValue[]Powershell 读取类型为 FieldUserValue[] 的 Sharepoint 列表项
【发布时间】:2020-06-12 09:04:38
【问题描述】:

SharePoint 列表有一列,其中包含 1 到 3 个名称。它的类型是FieldUserValue[]。 我从这里得到字段类型:

$FieldType = $Item[$Field.InternalName].GetType().name

 ForEach($ColumnName in $ListRow) {

     $ColumnName.LookupValue
                            # This yields "Robert Green" --only one name in this row/column       
                            # This yields "FieldUserValue[]" when multiple names in this row/column
 }

我已经尝试了几天来从该列中获取名称。有谁知道如何使用 Powershell 检索此类数据?

数据在 Sharepoint 列表中的显示方式:

列名

罗伯特·格林

列名

比尔·格雷

阿曼达·雷耶斯

莫莉曼陀罗

【问题讨论】:

  • 尝试foreach($name in $ColumnName.LookupValue) {$name} 或者$ColumnName.LookupValue -join ', ' 来获得一个逗号分隔的列表,如果这更适合您的话。

标签: powershell sharepoint-online


【解决方案1】:

读取多个用户字段值的示例脚本。

$userValueCollection = [Microsoft.SharePoint.Client.FieldUserValue[]]$item["Employee_x0020_Name"]

    foreach ($FieldUserValue in $userValueCollection)
    {
         write-host $FieldUserValue.LookupValue.ToString()
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-18
    • 2016-12-29
    • 2018-01-03
    • 2017-07-29
    相关资源
    最近更新 更多