Author Posts

March 7, 2016 at 5:40 pm

Hi,
I was trying to run some commands(Ex: get-odbcdsn) in powershell version 2.0 and it throws an error:

The term 'get-odbcdsn' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:12
+ get-odbcdsn <<<< + CategoryInfo : ObjectNotFound: (get-odbcdsn:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException But same command i was runing it in powershell version 3.0 and it works I want to set the DB using set-odbcdsn on windows server 2008 r2 with below command Set-OdbcDsn -Name "bwise_dwh" -DsnType "System" -Platform "64-bit" -SetPropertyValue "Database=bwise_dwh_dmz" but it is not working in windows server 2008 r2 but it is working in windows server 2012 Please help!!

March 7, 2016 at 6:34 pm

get-odcdsn was added with Windows 8 and Server 2012 which come with Powershell 3.0 by default. Systems running powershell 2.0 will not have the command.

https://technet.microsoft.com/en-us/library/hh771015(v=wps.620).aspx

March 7, 2016 at 6:51 pm

So which command use for to set Db name through odbcdsn in powershell version 2.0

March 7, 2016 at 8:21 pm

I'm not sure if there was any convenient scripting or command line tool for automating that prior to WS2012; a quick web search certainly didn't turn up anything along those lines. However, that search did at least give the registry location where the ODBC DSNs are stored: HKLM:\Software\ODBC\ODBC.INI\ (or HKCU:\ , for user DSNs instead of System).

Under the "ODBC Data Sources" subkey, you'll have something like "DSNName" = "SQL Server", and there will be a corresponding "DSNName" subkey under the ODBC.INI key. Under that subkey, it looks like you should have a "Database" value that you can modify.

Since you were starting with this command:

 Set-OdbcDsn -Name "bwise_dwh" -DsnType "System" -Platform "64-bit" -SetPropertyValue "Database=bwise_dwh_dmz" 

I think you could try this instead on 2008:

Set-ItemProperty -Path HKLM:\Software\ODBC\ODBC.INI\bwise_dwh -Name Database -Value bwise_dwh_dmz

Keep in mind, though, that I haven't tested this, and it's just an educated guess based on what I found on Google. 🙂 Try it out in a lab first.

March 9, 2016 at 2:56 pm

It Worked Thanks

March 25, 2016 at 11:33 am

Set-ItemProperty -Path HKLM:\Software\ODBC\ODBC.INI\bwise_dwh -Name Database -Value bwise_dwh_dmz

This is working only for 64-bit odbc conection not for 32-bit.
How can i change the Db for 32-bit.

March 25, 2016 at 11:53 am

For 32-bit DSNs on a 64-bit system, it's probably HKLM:\Software\Wow6432Node\ODBC\ODBC.INI\bwise_dwh , but you'll have to test to know for sure.

March 25, 2016 at 4:01 pm

Perfect!!!!! Thanks You So Much It Works.