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