Quantcast
Viewing latest article 3
Browse Latest Browse All 25064

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 an idea?

Regards and Thank you

Nickxx



Viewing latest article 3
Browse Latest Browse All 25064

Trending Articles