OK, so the goal of this script is to update a User Profile property (in this case Work E-mail) for several users having a CSV file as datasource.
Here goes:
- the CSV file should look like:
and here is the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#get users $data=Import-Csv C:\temp\scr\users.csv #Config Variables $AdminSiteURL = https://arachita1-admin.sharepoint.com #Connect to PnP Online Connect-PnPOnline -Url $AdminSiteURL -UseWebLogin #enum users and update work e-mail foreach ($line in $data) { #Write-Host "user is:" $line.user, "and mail is:" $line.mail #sharepoint online powershell update user profile property Set-PnPUserProfileProperty -Account $line.user -PropertyName "WorkEmail" -Value $line.Mail } |
Enjoy!