Typical use case is when someone gets married and their username is changed in active directory (AD). Each site collection has a list of users which are updated by an AD/SharePoint sync task, but it doesn't work well when a user's name changes. These command list all the problem site collections:
Get-SPWebApplication -Identity $Url | Get-SPSite -Limit All | Select-Object -ExpandProperty RootWeb | Get-SPUser -Limit All | Where {$_.LoginName -like $OldLoginName} | select Name, LoginName, ParentWeb
These command usually fixes the problem:
Get-SPWebApplication -Identity $Url | Get-SPSite -Limit All | Select-Object -ExpandProperty RootWeb | Get-SPUser -Limit All | Where {$_.DisplayName -eq $OldDisplayName -or $_.LoginName -eq $OldLoginName} | Set-SPUser -SyncFromAD
I'm getting following error.
Set-SPUser : Cannot get the full name or e-mail address of user
Any ideas ?