Unable To Run Some CMD, throws an Error

This topic contains 9 replies, has 3 voices, and was last updated by Profile photo of Vishal Joshi Vishal Joshi 8 months, 2 weeks ago.

  • Author
    Posts
  • #36216
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

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

  • #36218
    Profile photo of Jonathan Warnken
    Jonathan Warnken
    Participant

    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

  • #36219
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

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

  • #36223
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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.

  • #36342
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

    It Worked Thanks

  • #36448
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

    Thanks

  • #36976
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

    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.

  • #36977
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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.

  • #36984
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

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

  • #36985
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

    Thanks A Lot.

You must be logged in to reply to this topic.