Forum Discussion
JFM_12
Jul 14, 2020Iron Contributor
Sharepoint Powershell update Peoplepicker in List
Hello
I want to run a script that reads a csv and updates peoplepicker.
My code looks like:
Read the CSV file
$delimitercsv = "|" $filePath = "File.csv" $CSVData = Import-CSV -path $filepath -Delimiter $delimitercsv
SharePoint column names
$costcenter = "costcenter"
$userid = "User ID"
$useremailowner = "Owner"
Get the SharePoint List
$websitedirectory = Get-SPWeb -identity "website" $list = $websitedirectory.Lists["Site Directory"]
#Iterate through each row in the CSV and update the Owner Email
$items = $list.Items
foreach($item in $items | get-member -MemberType ‘NoteProperty’ | Select-Object -ExpandProperty ‘Name’) { $userid = $item['User ID'] $useridtest = $userid -replace ".*#" [Microsoft.SharePoint.SPUser]$useremail = $CSVData | Where-Object {$_.UsID -eq $userid} | % UsID $item[$useremailowner] = domain\$userid $item.Update(); }
Unfortunately it does not work.
Do you have any idea?
Regards and big thanks
JFM_12
No RepliesBe the first to reply