07 August, 2013

Operation is not valid due to the current state of the object

Every day we face some strange issues in SharePoint, if it’s working before then why it suddenly stops working! Big question-hmm??

Today we are going to discuss one similar scenario and I am pretty much sure you will comes up with different resolution’s because this issue might vary from environment to environment so resolutions might be different.

Problem description:
One of our content database has already reached the 100GB mark so as per Microsoft recommendations, it’s better to move the site collections to new database as it might create some problems while doing backup and restore. So the plan to move some site collections from existing database to new database. For this purpose, we have created a new database by means of central administration.

One thing I wanted to clear that we are doing backup-restore activity, we are moving some heavy site collections between databases only.
In SharePoint 2010, we have an inbuilt command to move the site collections between databases, please refer the following:

Move-SPSite <http://ServerName/Sites/SiteName> -DestinationDatabase <DestinationContentDb>

So we make modifications as per our databases i.e. URL of the site collection and name of the destination database.

As soon as we hit enter, the PowerShell command throws an exception as mentioned below.

Error message:
Move-SPSite: Operation is not valid due to the current state of the object

Troubleshooting done:
-Checked the status of site collection-whether it’s set to lock/read only?

-Checked the status of the database-whether it’s online/offline?

-Tried detaching the source and destination databases and reattached again but still no results

-Tried moving site collections to existing databases- this one works!

-Tried creating a site collection in newly created database- works!

-The site that we have just moved to existing DB- tried moving to the destination database (where we are facing to problem)- Failed!

-Tried creating a new database for different web application and performed the same operation- Failed!

-checked the health analyser again to verify for any new errors

-Found this error which we have neglected-Databases running in compatibility range, upgrade recommended.

<This is the main culprit>

Resolution:
We ran this command on the source database from which we were trying to move the site collections to destination database.

upgrade-contentdatabase -Name <> -Webapplication <>

Operation completed successfully.

Tried running the move-spsite command and executed successfully without any issues…

By this way we have overcome this error message but as I mentioned in the beginning resolution might vary from environment to environment so request you to please share if you have different resolution part from the above mentioned so that it would be beneficial to others as well.

If you have any queries/questions regarding the above mentioned information then please let me know, I would be more than happy to help you as well resolves your issues, Thank you.

Product Applies To:
SharePoint Server 2010
SharePoint Foundation 2010
SharePoint Server 2013

No comments:

Post a Comment

Your feedback is always appreciated. I will try to reply to your queries as soon as possible- Amol Ghuge

Note: Only a member of this blog may post a comment.