I faced "Access Denied" error problem when I try to run the command "Test-SPcontentDatabase" with both the required params Name& Webapplication.
In My scenario, my SharePoint 2007 content Database is not residing on the same server as that of my 2010 farm configuration database. Also both the SQL servers are appearing as part of the farm when I visit The Servers in the Farm Page.
When I ran the command "Test-SPContentDatabase" and visited the Event Viewer, I found a event with event Id: 3760 saying
SQL Database 'WSS_Content_
Cannot open database "WSS_Content_
Login failed for user
From the above error, I understood that the SharePoint is trying to find the database on the wrong Server (the hosting the Configuration database). Obviously It cannot find the database. Then I tried the same command with the Parameter "-ServerInstance" and it worked like a charm... :-)
Update: Today when I was doing SharePoint 2007 to SharePoint 2010 upgrade i got the same issue and this time even after specifying the ServerInstance Parameter. The error message is:
“Test-SPContentDatabase : The server instance of the database could not be found.”
Get-SPContentDatabase -ConnectAsUnattachedDatabase -DatabaseServer