This blog post is going to cover a scenario where a, perhaps, confusing error message is returned to a SharePoint administrator when trying to verify the health/suitability of a content database by using Test-SPContentDatabase
I had been working with a customer on some health reporting scripts, and one of the validation steps was to run Test-SPContentDatabase against databases that were identified to contain orphaned apps. While manually running Test-SPContentDatabase, under the context of the SharePoint Farm Administrator account the SharePoint administrator received a very confusing message. The message was: ‘Cannot open database [DatabaseName] requested by the login. The login failed.’
As we were very sure that the farm account had sufficient rights to access this database (everything else appeared to be working normally and we had run other PowerShell cmdlets against this database in the past) we were suspicious that the error message returned may have been erroneous.
We just took a quick look at the available parameters for this cmdlet using Get-Help
A quick look through the parameters, and we knew that we had simply forgotten to specify the ServerInstance parameter. This was necessary because the database we were testing was not located on the default database server (I would love to link to an official Microsoft article that explains where and how to do this, but the latest article I can find on this topic is for SharePoint 2007 – nonetheless, it is a pretty straightforward process)
As suspected, the error message was incorrect. This was not a logon issue, SharePoint was looking for a database on an instance where it did not exist. In the end, we simply added the –ServerInstance parameter, and Test-SPContentDatabase completed successfully
As always, if you do have any feedback or suggestions, I’d love to hear from you.
You can also follow me on twitter @RCormier_MSFT