List ODBC System DSN for all machines in Domain

Hi EE,

I need some help with a excel vba script to list all System DSN for every machine in my domain.

i know they are stored in the registry here.

HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI

So the script is going to have to find all machines and then loop and read the registry.

it has  got me banging my head of the desk so any help will be a great help.

Thank you

Ross
LVL 7
Ross TurnerManagement Information Support AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

x-menIT super heroCommented:
'connect to the root of AD
Dim rootDSE, domainObject
Set rootDSE=GetObject("LDAP://RootDSE")
domainContainer = rootDSE.Get("defaultNamingContext")  '<--Your Domain
Set oDomain = GetObject("LDAP://" & domainContainer)
 
'start with the domain root
WorkWithObject(oDomain)
 
Sub WorkWithObject(oContainer)
Dim oADObject
For Each oADObject in oContainer
  Select Case oADObject.Class
 
   Case "computer"
    'oADObject represents a COMPUTER object;
    'do something with it
   
    Set objReg = GetObject("winmgmts:{inpersonationlevel=impersonate}!\\"&oADObject.Name&"\root\default:StdRegProv")
    objReg.EnumValues &H80000002,"SOFTWARE\ODBC\ODBC Data Sources",arrValueNames,sType
    For i=0 to UBound(arrValueNames)
                ValueName = arrValueNames(i)
                objReg.GetStringValue &H80000002,"SOFTWARE\ODBC\ODBC Data Sources",ValueName,sValue
                WScript.Echo oADObject.Name&vbTab&ValueName&vbTab&sValue
    Next
  End select
Next
End Sub
0
RobSampsonCommented:
There is code that retrieves the System ODBC settings from computers in computers.txt if you want to try it out.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_27970324.html#a39005367

Regards,

Rob.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ross TurnerManagement Information Support AnalystAuthor Commented:
Champion!!!  cheers Guys :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.