locked
problems adding odbc with PS script RRS feed

  • Question

  • testing adding a odbc connection via PS script. but am getting attached error:

    the script is pretty basic, also attached.

    thanks for any suggestions

    PS C:\> Add-OdbcDsn -Name "MyPayroll" -DriverName "SQL Server Native Client 10.0" -DsnType 
    "System" -SetPropertyValue @("Server=MyServer", "Trusted_Connection=Yes", "Database=Payroll")

    The term 'Add-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, v
    erify that the path is correct and try again.
    At line:1 char:22
    + $newDsn = Add-OdbcDsn <<<<  -Name "MyPayroll" -DriverName "SQL Server Native Client 10.0" -DsnType "System" -SetPropertyValue @("Server=sirvsap02", "Trusted_Connection=
    Yes", "Database=m2mdata01") -PassThru
        + CategoryInfo          : ObjectNotFound: (Add-OdbcDsn:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    Sunday, July 30, 2017 9:49 PM

Answers

All replies

  • That CmdLet is not available in earlier versions of PowerShell and only available since Windows 2012/8.


    \_(ツ)_/

    Sunday, July 30, 2017 9:54 PM
  • ODBC is a Win component,to add/edit,open ADM tools,locate ODBC,open,edit its properties.The ODBC

    services must be configured.Also,at least with many/all Win OS,one opens cmd or run,type: MMC  in MMC

    edit console,add/remove components,ODBC is available,rest is fairly simple....

    Also,as far as scripts go,go to TechNet script center,a script that youre looking for may be available.

    https://gallery.technet.microsoft.com/scriptcenter

    Sunday, July 30, 2017 9:58 PM
  • There is no scripts for creating a DSN in the Gallery. Support for the new ODBC connections was not added to Windows until 8/2012.  There are ways to add the DSN to the registry or to create a file DSN with PowerShell with earlier versions of Windows.

    I do not believe the CmdLet is available without upgrading PS on W8/2012 to WMF 4.

    The old ODBC manager is available on all versions of Windows back to at least Windows 2.0.  Before MMC it was a control panel setting.

    The non-MMC version of ODBC is available by typing odbcad32 at any prompt.


    \_(ツ)_/


    • Edited by jrv Sunday, July 30, 2017 10:10 PM
    Sunday, July 30, 2017 10:08 PM
  • Also the old config is still available for command line creation of DSNs and installing ODBC drivers.

    odbcconf /?


    \_(ツ)_/

    • Marked as answer by jrv Wednesday, October 17, 2018 10:03 PM
    Sunday, July 30, 2017 10:12 PM
    • Marked as answer by jrv Wednesday, October 17, 2018 10:01 PM
    Sunday, July 30, 2017 10:14 PM
  • Hi,
    Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance.

    Best Regards,

    Frank

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, August 3, 2017 2:05 AM
  • I have PS version 5.1.14409.1012 and I do not have the Add-ODBCDSN cmdlet. How do I get it?

    Wednesday, October 17, 2018 8:37 PM