Tuesday, September 21, 2010

Enumerating SQL Server DBs

Does anyone have a VBScript (that can be run from the command line) that can enumerate the databases (and their attributes) on a SQL Server - NOT using SQLDMO ?
IE - not like the one below

strDBServerName = "."

Set objSQLServer = CreateObject("SQLDMO.SQLServer")
objSQLServer.LoginSecure = True
objSQLServer.Connect strDBServerName

Set colDatabases = objSQLServer.Databases

For Each objDatabase In colDatabases
WScript.Echo objDatabase.Name
Next Set colDatabases =NOTHING
Set objSQLServer =NOTHING


My problem is that a standard (non SQL installed) machine doesn't have SQLDMO installed as far as I can tell - please correct me if I am mistaken. Basically I want to use the normal audit_windows.vbs script to enumerate all databases on a server and their size (and anything else that you might find interesting). Can anyone help ?

UPDATE - I found an example script, incorporated it into the audit script and it's all good. I created a basic "Show Databases" report and it works.

No comments:

Post a Comment