CU Updates, Big Farm, Lots of DB’s, Mounting Databases

Let’s say you have this ginormous farm with hundreds of databases and you want to update the farm to a new CU.  First thing you can do is get a list of your content databases using this powershell


Once you’ve got that list of database names and you know the associated web application URL, you can go ahead and dismount the databases, and one way to do that is with a modified version of the script you will use to mount the databases.  The way it works is you get the database names in a text file and then call this powershell:

Note: This example assumes you know the name of the text file and the path to it.  You save this powershell in a .ps1 file and you put the ps1 in the same directory where you have the databases.txt file.  If you used the above powershell verbatim, then you need to change either the name of the text file from PathtoFile.txt to databases.txt, or you need to change the script that follows,  Your call boss, you are in charge here!

Make sure the text file is just a list of database names and if you used the get-spcontentdatabase command above, make sure to remove the header info and the dashed lines, else SharePoint will try to create a database named name and ——-

Notice: on line 8 above, we’ve got Dismount-spcontentdatabase being called into action, like some sort of rebel force, bent on the dismounting of all databases that were attached to whatever web application you entered into the screen when prompted….and oh ya!  you will be prompted when you run this command.  You will want to make sure you enter the exact URL of the web application including the http:// or https:// , e.g.

Then go ahead and apply the CU to your SharePoint farm

When finished it is time to mount the databases back to the web application using the following powershell


Please take notice of line 10, this time we are mounting databases.

Finally, you will probably want to make sure all the databases are upgraded, so you can run this:

and if you get any errors, try this one


A couple of gotchas with this approach:


  • If your databases have been moved around alot between environments, some of them may have orphaned top sites, meaning make sure you know which database is attached to the top of each web application and make sure to mount that database first, as the get-spcontentdatabase cmdlet does not give you this info. If you fail to do this you could end up with the wrong content on the top of the site and a really bad user experience.  Now nobody wants that, right?!??
  • Make sure to attach the databases to the correct web application.  This is why it’s so paramount to know your environment, not only with that first gotcha that you just read, but also with the overall topology of your farm.

I hope this helps someone down the road of their epic SharePoint journey.  Please hit me up at if you have any questions about this post or any suggestions on how I could improve it.  Make it a great day and have a good one!

Happy SharePointey goodness to you and yours!