Thursday, August 27, 2015

One problem with Set-SPUser cmdlet

When you use Set-SPUser cmdlet which sets user properties, e.g. email:

Set-SPUser -Identity "domain\username" -Web -Email

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 -Email

It should fix the problem.


  1. This solved my problem! Thanks!
    (also applies for the Get-SPUser cmdlet)

  2. Hi,

    what about if I want to sync Email with AD ?

    Set-SPUser -Identity "i:0#.w|domain\username" -Web -SyncFromAD

    Set-SPUser : Cannot get the full name or e-mail address of user "i:0#.w|XXX\XXX".

  3. Franck,
    can it be so that in your case you need to use user name in "domain\username" (not claims) format

  4. Hello Alexey,

    Manually updating user properties, like Email, is ok using your command below
    --> Set-SPUser -Identity "i:0#.w|domain\username" -Web -Email

    But what if I want to change Email property from AD using the
    -SyncFromAD ?


  5. and you sure that email is specified in AD for the user which you try to update?

  6. ok, 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

  7. Excellent post! I was getting exactly the same issue and had no idea how to fix it. The trick worked like charms.