使用PoweShell PnP更新SharePoint Online列表中的查找列

时间:2020-11-09 07:46:41

标签: powershell sharepoint sharepoint-online

我已经研究过PowerShell PnP脚本来更新基于云的SharePoint列表中的列。 我想用“ FH ID”中的内容更新“ Parent ID”列。我的脚本在常规列上运行良好,但是“父ID”是一个查找列,因此,它具有三个值:LookupID,LookupValue和TypeId(请参见图片)。我的脚本更新了LookupId,但我们需要它来更新LookupValue。

任何人都可以提供解决方案吗?

在下面的脚本中,我们正在测试一个“ FH ID” = 1020

enter code here

Connect-PnPOnline https://skat.sharepoint.com/sites/ICIfo

 function UpdateColumn(){
 $listName = "FH kontakt"

 $list = Get-PnPList $listName

 $items = Get-PnPListItem $listName

  foreach ($item in $items){
  if ($item["FH_x0020_ID"] -eq "1020"){
  Write-Output $item["FH_x0020_ID"]
  Write-Output $item["FH_x0020_Navn"]
  Write-Output $item["Parent_x0020_ID"]
  Write-Output ""
  Set-PnPListItem -List $listName -Identity $item -Values @{"Parent_x0020_ID" = $item["FH_x0020_ID"]}
  }
  }
  }

  UpdateColumn

1 个答案:

答案 0 :(得分:0)

要在线更新SharePoint中的查找列,您需要获取父查找项目的ID。

您可以参考这篇文章以获取更多信息:

https://www.sharepointdiary.com/2017/03/sharepoint-online-powershell-to-update-lookup-field.html