Thursday, April 2, 2015

Move-SPUser Failed with error "The site with the id "GUID" could not be found.

Scenario

Think about this scenario,  you are trying to run the migrate user command to migrate the user from one ID to new id in he certain situation.
  1. User ID get deleted from AD and recreated but with new SID
  2. User id change from One Domain to other domain
  3. User ID got changed after her last name changed.
You run the following command:
PS C:\temp>$user = Get-SPUser -web https://webapplication url-Identity "domain\username"
PS C:\temp>Move-SPUser -Identity $user -NewAlias "domain\testuser" –IgnoreSID -Confirm:$false
Move-SPUser : The site with the id ebaf8908-78B9-4BAF-9845-56556B2BE628 could not be found.
At line:1 char:12
+ Move-SPUser <<<<  -Identity $user -NewAlias "domain\testuser" -IgnoreSID
    + CategoryInfo          : InvalidData: (Microsoft.Share...PCmdletMoveUser:
   SPCmdletMoveUser) [Move-SPUser], FileNotFoundException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletMoveUser
 

Even with Stsadm command:

stsadm.exe -o migrateuser -oldlogin "domain\user" -newlogin "domain\testuser" -ignoresidhistory
The site with the id ebaf8908-78B9-4BAF-9845-56556B2BE628 could not be found.
Now if you trying to get the details about the Site ID & run the below command:
 PS C:\temp>get-spsite  -identity "ebaf8908-78B9-4BAF-9845-56556B2BE628"
Get-SPSite : Cannot find an SPSite object with Id or Url: ebaf8908-78B9-4BAF-9845-56556B2BE628.
At line:1 char:11
+ get-spsite <<<<  ebaf8908-78B9-4BAF-9845-56556B2BE628
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:
   SPCmdletGetSite) [Get-SPSite], SPCmdletPipeBindException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite
 

Reason:

Migrate / Move user go through all sites in the content databases & User Profile. If there is any orphan sites in the content database then this issue occurred.

Identify:

If you have only few content databases in your farm then run the below mentioned script against each content DB and see if its worked.
Select * from userinfo with (nolock) where tp_siteid like '%ebaf234348-78B9-4VAF-9845-56556B2BE628%'
If you have many databases across on couple of servers then run this
EXEC sp_MsForEachDb 'use [?]; SELECT "?" AS [databasename], ID FROM [?].dbo.AllSites with (Nolock) WHERE ID = "ebaf234348-78B9-4VAF-9845-56556B2BE628"'
You will get the Database name and ID.
Server NamedatabasenameID
Database ServerContentDatabaseebaf234348-78B9-4VAF-9845-56556B2BE628

Resolution:

Method # 1

You need to detach the content Databse and re attach it back to Web app will clear the orphan.
To detach a content database by using Central Administration
  1. Verify that the user account that is performing this procedure is a member of the Farm Administrators SharePoint group.
  2. On the SharePoint Central Administration website, click Application Management.
  3. On the Application Management page, in the Databases section, click Manage content databases.
  4. Select the web application for which you want to detach a content database.
  5. Click the content database that you want to detach.
  6. On the Manage Content Database Settings page, select the Remove content database check box.
If the content database contains data, you will receive a warning. Click OK to continue with the operation.
  1. Click OK to confirm the detachment, or click Cancel to stop the operation without detaching the database.
After detaching the content database in Central Administration, the content database still exists in SQL Server.
To attach a content database by using Central Administration
  1. Verify that the user account that is being used to perform this operation is a member of the Farm Administrators SharePoint group.
  2. Start SharePoint 2010 Central Administration.
  3. On the SharePoint Central Administration website, click Application Management.
  4. On the Application Management page, in the Databases section, click Manage content databases.
  5. On the Manage Content Databases page, click Add a content database.
  6. On the Add Content Database page:
    1. Use the web Application drop-down menu to select the web application to which you want to attach a content database.
    2. Specify the database server that hosts the database.
    3. Specify the database name. If the database does not already exist, it will be created.
    4. Specify the authentication method for the database, and supply an account name and password if you are using SQL authentication.
    5. Click OK.

Method # 2

If above method failed, then you have to create a new content Database and move all working sites except orphan to the newly created Database.

Total Pageviews