I am trying to update DSNs on multiple different user boxes, which should be running Windows 7 x64. People have sometimes created their own DSNs (maybe System, maybe User), and other places where admins have. I want to replace the servername when it's a particular value, with a CNAME for that box.
I read this article, which seemed a good start: http://www.sqldataplatform.com/Blog/Post/9/Modifying-ODBC-Settings-with-WMI-and-PowerShell
However, when testing this on my box, I ran into a problem where I don't see the System DSNs I expect.
When I run the 64-bit "Data Sources (ODBC)" (C:\Windows\system32\odbcad32.exe), which is the default when you go to Start->Administrative Tools->Data Sources, then I see the data source I created. However, this doesn't work:
Get-ChildItem -path "HKLM:\SOFTWARE\ODBC\ODBC.INI\"
Instead, I get a System DSN that I created in the 32-bit version of Data Sources (ODBC), aka "C:\Windows\SysWOW64\odbcad32.exe"
Oddly, if I run this, I get the exact same 32-bit DSN, where I'd expect to get the 32-bit and the 64-bit, even though I see them in different nodes when I open my registry.
Get-ChildItem -path "HKLM:\SOFTWARE\ODBC\ODBC.INI\"
Get-ChildItem -path "HKLM:\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\"
So, any idea how I go about getting the other DSN? Thanks.
To see the 32-bit one, you need to run C:\windows\SysWOW64\odbcad32.exe. To see the 64-bit one, just run odbcad32.exe (from System32).
If you're running a 32-bit powershell session, you will only see the 32-bit one. If you're running a 64-bit session, you can see both.