How to Update User Email Address in SharePoint using PowerShell?
Problem: SharePoint workflows failed because, user has no email address!

You can get the user's Email address with this PowerShell one-liner:
Solution is simple! SharePoint user has no email address, so add email address to users to resolve the issue!
How to update SharePoint user email address?
To update user email address, Use, Set-SPUser cmdlet. Here are some examples:
Syntax:
Change user email address from Active Directory:
You can Sync User's Email ID from Active Directory
PowerShell script to update User Email address for all Sites in the web application:
Use this script to update user's Email address for the entire web application.

You can get the user's Email address with this PowerShell one-liner:
(Get-SPUser -Identity "Crescent\bourgeois" -Web "http://portal.crescent.com/projectpipeline").email
Solution is simple! SharePoint user has no email address, so add email address to users to resolve the issue!
How to update SharePoint user email address?
To update user email address, Use, Set-SPUser cmdlet. Here are some examples:
Syntax:
Set-SPUser -Identity "i:0#.w|Domain\username" -Email "[email protected]" -Web http://sharepoint-site-urlExample:
Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -Email "[email protected]" -Web http://intranet.crescent.com/This sets the Email ID of the user to given Email for entire site collection.
Change user email address from Active Directory:
You can Sync User's Email ID from Active Directory
Set-SPUser -Identity "i:0#.w|Domain\username" -Web "http://sharepoint-site-url" -SyncFromAD Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -Web "http://intranet.crescent.com/" -SyncFromADThis script syncs user properties such as Display Name, Email, Department, etc from Active directory. Here is the result of updated user Email:
PowerShell script to update User Email address for all Sites in the web application:
Use this script to update user's Email address for the entire web application.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $WebAppURL="http://intranet.crescent.com" $UserAccount="i:0#.w|Crescent\Salaudeen" #Update Email for all sites in the web application Get-SPWebApplication $WebAppURL | Get-SPSite -Limit All | Foreach-object { Write-host "Processing:" $_.Rootweb.URL #Get the User's Current Display Name and E-mail $User = Get-SPUser -Identity $UserAccount -Web $_.Rootweb.URL if($User -ne $null) { Set-SPUser -Identity "i:0#.w|Crescent\Salaudeen" -Email "[email protected]" –Web $_.Rootweb.URL } }To Sync All user details such as Email, Display name, etc from Active directory, use:
Get-SPUser -Web http://web-app-url | Set-SPUser –SyncFromAD
How to Update User Email Address in SharePoint 2007 using stsadm.exe ?
ReplyDeleteCould you please send the command for SP 2007.
Try Full profile Import!
DeleteThanks for sharing. It worked very well.
ReplyDeleteHi
ReplyDeleteI tried this Get-SPUser -Web http://web-app-url | Set-SPUser –SyncFromAD, but gives error - can not get the full name or email address of user error- any inputs pls.