使用客户端powershell将csv文件导入包含查找的SharePoint列表

使用客户端powershell将csv文件导入包含查找的SharePoint列表,csv,powershell,sharepoint,Csv,Powershell,Sharepoint,我有一个csv文件,可以使用客户端powershell将数据导入包含单行文本和多行文本的SP列表,但无法导入查找值。如何将csv中的该列导入查找列。(这就是如何动态设置查找id的方法) 其中,$row变量是csv行 #For Lookup values: Lookup Parent List $DepartmentList=$web.Lists["Department"] #Get the Lookup Item from Parent List $LookupItem = $de

我有一个csv文件,可以使用客户端powershell将数据导入包含单行文本和多行文本的SP列表,但无法导入查找值。如何将csv中的该列导入查找列。(这就是如何动态设置查找id的方法)

其中,$row变量是csv行

#For Lookup values: Lookup Parent List
$DepartmentList=$web.Lists["Department"]

   #Get the Lookup Item from Parent List
   $LookupItem = $departmentList.Items | Where-Object { $_.Item("Title") -eq $row.Department}

if($LookupItem -ne $null)
{
         $deptLookup = New-Object Microsoft.Sharepoint.SPFieldLookupValue($LookupItem.ID,$row.Department)
}

     #Set the Lookup field value
     $item["Department"] = $deptLookup

   $item.Update()


Read more: http://www.sharepointdiary.com/2013/04/import-from-csv-file-to-sharepoint-list-using-powershell.html#ixzz40VmbNqi0