• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 421
  • Last Modified:

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.


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 Turner
Ross Turner
2 Solutions
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
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
  End select
End Sub
There is code that retrieves the System ODBC settings from computers in computers.txt if you want to try it out.



Ross TurnerManagement Information Support AnalystAuthor Commented:
Champion!!!  cheers Guys :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now