Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
1.9k views
in SharePoint Server by 12 13 21

I am trying to use Set-SPUser cmdlet in SharePoint PowerShell to sync data from AD to information list but when running the below cmdlet I got this error "You must specify a valid user object or user identity."

$web | Set-SPUser -Identity "ransman@mydomain" -SyncFromAD

Details error

You must specify a valid user object or user identity SharePoint 2019

PS C:\Users\ransman> $web | Set-SPUser -Identity "ransman@mydomain" -SyncFromAD
Set-SPUser : You must specify a valid user object or user identity.
At line:1 char:8
+ $web | Set-SPUser -Identity "ransman@mydomain" -SyncFromAD
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-SPUser], PSArgumentException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletSetUser

1 Answer

1 like 0 dislike
by 162 202 397
selected by
 
Best answer

Solving: You must specify a valid user object or user identity.

In SharePoint PowerShell, If you get this error "You must specify a valid user object or user identity" that means the provided user is not in the correct format.

The valid user format should be in this format "i:0#.w|DomainName\UserName", so in your case, you have to run the Set-SPUser cmdelt with this valid-user

$web | Set-SPUser -Identity "i:0#.w|DomainName\UserName" -SyncFromAD
by 12 13 21
0 0
This solved my error, thanks alot
If you don’t ask, the answer is always NO!
...