1

I have working Sharepoint 2010 script that modifies e-mail for the web site user. The problem is - the script doesn't work on Sharepoint 2013. I am not able to modify its e-mail. I tried to modify it through Profile Synchronization with AD, but no luck. Then I got this script, but it seems that it works only on SP 2010. Any ideas? What I want to achieve is modified user's contact card, with modified e-mail, at Site Settings -> People and Groups -> web-site Members

cls  
$web =Get-SPWeb http://sp2013/sites/wooly/
$list=$web.Lists["User Information List"]
$user =$list.GetItemById(##)
$user["SipAddress"]=""
$user["EMail"]="[email protected]"
$user.update()
$list.update()

$web.update()

1 Answer 1

3

I could add/change the user’s missing email address using PowerShell. Here is the code that I used:

Add-PSSnapin Microsoft.Sharepoint.Powershell
$web = get-spweb "SiteCollection URL" 
$user = $web.EnsureUser("domain\username") 
echo $user
Set-SPUser -Identity $user -Email "[email protected]" -Web "SiteCollection URL"
Remove-PsSnapin Microsoft.SharePoint.PowerShell

put the above code in Windows Powershell ISE and execute it.

If you provide a valid user name, echo $user command will display the user's display name and user's login,

Note that if you have many site collections you may need to make this change for each one (give the site collection URL in the -web option).

Hope this helps you.

9
  • Hi I wrote PS C:\Users\administrator.CMBUQA> Set-SPUser -Identity "testqa\katarina1" -Email "[email protected]" -Web sp2013/sites/wooly and I am getting error "Set-SPUser : You must specify a valid user object or user identity." Does this mean I have the wrong user, or non-existing user?
    – Zarko
    Commented Sep 26, 2013 at 13:23
  • to check for the valid user name, use the below command, after checking it, you can change the email id of a particular user." $web = get-spweb sharepointdns/site/site $web.EnsureUser("DOMAIN\user") " Commented Sep 26, 2013 at 13:28
  • System is not able to find the specified user, it could be wrong user or non-existing user. Commented Sep 26, 2013 at 13:32
  • PS C:\Users\administrator.TESTQA> $web = get-spweb sp2013/sites/wooly $w eb.EnsureUser("TESTQA\katarina1") Get-SPWeb : A positional parameter cannot be found that accepts argument 'i:0#.w|testqa\katarina1'. At line:1 char:9 + $web = get-spweb sp2013/sites/wooly $web.EnsureUser("TESTQA\katarina1") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-SPWeb], ParameterBindi ngException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.SharePoint .PowerShell.SPCmdletGetWeb
    – Zarko
    Commented Sep 26, 2013 at 15:38
  • Any ideas why I am getting this error?
    – Zarko
    Commented Sep 26, 2013 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.