powershell_iconI wanted to share this quick tip with PowerShell.  Many times, we need to have an easy way to find the configuration database, and like a good SharePoint administrator, you want to try and use PowerShell.  I have come across other blogs here and others that mention finding this with the registry, so this is just another way to do it.

There are many commands that deal with databases, but only one that gives us what we need - Get-SPDatabase.  This cmdlet will show all different types of databases including configuration, content, and service application databases for the farm.  Knowing this, we’re already halfway there.  By default, this cmdlet spits out the Name, ID, and Type of the databases in the farm.

Knowing the type, we can use filtering to get exactly what we need.  Run this command:

Get-SPDatabase | Where-Object { $_.TypeName -eq "Configuration Database" }

This limits the output and only gives us what we’re looking for, the configuration database.  That was easy!  To see all the valid types of databases for your farm, you can run the following:

Get-SPDatabase | select TypeName –unique


If we didn’t have the –unique switch, you would list duplicate entries for databases where you had multiples of, like Content Database.  If you want to dig into the content databases, you can use Get-SPContentDatabaseHere’s a list of all the cmdlets for SharePoint databases.  Enjoy!