When you use Set-SPUser cmdlet which sets user properties, e.g. email:
Set-SPUser -Identity "domain\username" -Web http://example.com -Email user@example.com
you may get the following error message:
You must specify a valid user object or user identity
This error may be shown if your web application uses claims-based authentication, but you specified username in command line arguments in regular Windows format: domain\username. In order to avoid this error try to use claims format for username:
Set-SPUser -Identity "i:0#.w|domain\username" -Web http://example.com -Email user@example.com
It should fix the problem.
This solved my problem! Thanks!
ReplyDelete(also applies for the Get-SPUser cmdlet)
Hi,
ReplyDeletewhat about if I want to sync Email with AD ?
Set-SPUser -Identity "i:0#.w|domain\username" -Web http://example.com -SyncFromAD
Set-SPUser : Cannot get the full name or e-mail address of user "i:0#.w|XXX\XXX".
Franck,
ReplyDeletecan it be so that in your case you need to use user name in "domain\username" (not claims) format
Hello Alexey,
ReplyDeleteManually updating user properties, like Email, is ok using your command below
--> Set-SPUser -Identity "i:0#.w|domain\username" -Web http://example.com -Email user@example.com
But what if I want to change Email property from AD using the
-SyncFromAD ?
Thanks
and you sure that email is specified in AD for the user which you try to update?
ReplyDeleteYes I am :)
ReplyDeleteok, asked just in case) as I didn't faced with this issue by myself just may suggest to continue googling about this problem and if you will find solution it would be great if you will share it here
ReplyDeleteExcellent post! I was getting exactly the same issue and had no idea how to fix it. The trick worked like charms.
ReplyDelete