Sunday, December 23, 2018

Update SharePoint User Profile work email into specific Web Application

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  
$WebAppURL="http://contoso.com"
$UserAccount="i:0#.w|Contoso\Nagaraju.Pattem"
 
#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|Contoso\NAgaraju.Pattem" -Email "Naga@Contoso.com" –Web $_.Rootweb.URL
    }
}

No comments:

Post a Comment