Unable To Run Some CMD, throws an Error

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!!

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

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

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. :slight_smile: Try it out in a lab first.

It Worked Thanks

Thanks

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.

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.

Perfect!!! Thanks You So Much It Works.

Thanks A Lot.