I need to get a list of SQL server instances present on a computer, get a list of databases in each instance, and then determine how much space each database is taking up.
I can easily grab the instance names from the registry, but I don’t have access to query the tables to get the names of the databases. Is there another way of doing this, maybe though WMI?
After some digging around, I finally found the WMI Class that will get my the info I need. On a server where I have 3 instances of SQL Server, I found my data in the following classes
My instances are
MSSQLINST2,MSSQLINST3andMSSQLSERVER. I couldn’t figure out the naming scheme, so I had to look though all the classes to find out the information I needed. Anyway, here’s the code that’s working. Maybe someone will find it useful.