Migrating users from one domain to another, I get this error on a couple of users. The migration still seems to occur.
Move-SPUser : pixels
At D:\UserMigration\MigrateUsers.ps1:10 char:28
+ $siteUser | Move-SPUser <<<< -NewAlias $user.usernameAfter -IgnoreSID
+ CategoryInfo : InvalidData: (Microsoft.Share...PCmdletMoveUser:
SPCmdletMoveUser) [Move-SPUser], UserProfileException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletMoveUser
I loaded up a CSV full of before/after usernames and ran it on the list, and two of the users generated this error.
$user is just the CSV row, usernameAfter is the second column in that row.
$siteUser is an SPUser object created from $site.RootWeb.AllUsers[$user.usernameBefore].
Paraphrased script used:
$users = Import-CSV D:\UserMigration\MigrateTheseUsers.txt
$site = Get-SPSite https://sharepointsite.com
$web = $site.RootWeb
foreach($user in $users)
{
$siteUser = $web.AllUsers[$user.usernameBefore]
Write-Host User Before:
$siteUser
$siteUser | Move-SPUser -NewAlias $user.usernameAfter -IgnoreSID
$siteUser = $web.AllUsers[$user.usernameAfter]
Write-Host User After:
$siteUser
}
Is this something I should be concerned about?
Update 1 Okay, I have one additional user that I receive this error for and the user does not get migrated. As circumstance has it, that user is my boss. Both a source and target user profile exist already but this has not been a problem in the past.
Update 2 I tried using stsadm instead to do the migration. I got the same result, without the PowerShell exception wrapper. I think this may be a generic exception bubbling up from the object model that just, for whatever reason, contains the text "pixels".
ULS shows the following error in the logs:
System.Data.SqlClient.SqlException:
Cannot insert duplicate key row in object 'dbo.UserInfo' with unique index 'UserInfo_Login'.
The statement has been terminated.
Without digging too deep into SQL, I'm not really sure what I can do about this without tainting the explicit "No direct DB operations!" rule of SharePoint. The relevant index is on the site ID, the login, and the deleted flag. I know I've migrated users before that have used both their old and new accounts at the same time, so that shouldn't be the issue.