It’s time for another PowerShell script. This one I wrote in a project where I needed to know what content databases was used by each farm. We had a large SQL cluster and more then one farm was using it. Since there is no enum content databases in stsadm i made this simple PowerShell script.
What it does basically is that it connects to the SPWebService and for each web application it finds it lists all SharePoint Content Databases and writes it to a text file.
This is how you use it:
.\SP-EnumContentDBs -path e:\contentdb.txt
And now in the first version you will get the following information:
Web Application name
Content Database Name
Content Database ID(GUID)
Current amount of sites in DB
Maximum site count allowed in DB
Read only state
But it’s easy to add more attributes by just adding more properties to the code. You can find all available properties at msdn: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spcontentdatabase_properties.
If you want to make a comparison to what you have on the SQL server you can easily run the script, import it to e.g. Excel and then run the following on the SQL server to get the list of databases:
select name from master..sysdatabases where dbid>4 order by name
You can download the script by clicking here, or it’s available at the download section.
Finally thanks to Travis Lingenfelder who with his blog post helped me with some strugeling getting the names out since it differs some from c#.









It‘s quite in here! Why not leave a response?