深入浅出PowerShell——更新List Item中的PeopleandGroup 域值

说明:目标站点HR中的列表Location中PeopleandGroup 域LSR,需要添加人员

$curWeb = Get-SPWeb ""
$curWeb = Get-SPWeb "https://tst15.emdev.azcollaboration.com/operations/Operations/HR"
[Microsoft.SharePoint.SPList]$curList = $curWeb.Lists["Location"]
[Microsoft.SharePoint.SPListItem]$curItem = $curList.GetItemById(1)

write-host $curItem["LSR"]
19;#Lui, Mingle (IBM)

$userValue.LookupId
21

$targetUser = $curWeb.EnsureUser("ibm\10086")
[Microsoft.SharePoint.SPFieldUserValue]$userValue = new-object Microsoft.SharePoint.SPFieldUserValue($curWeb,$targetUser.ID,$targetUser.Name)

$curItem["RSR"]=$userValue
$curItem.Update()

posted @ 2011-08-30 11:33  风影极光  阅读(213)  评论(1编辑  收藏  举报