PowerShell Logo Small

Add-OdbcDsn



This is the built-in help made by Microsoft for the command 'Add-OdbcDsn', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Adds an ODBC data source name into the system.

SYNTAX


Add-OdbcDsn [-Name] <String> [-AsJob [<SwitchParameter>]] [-CimSession <CimSession>] [-PassThru [<SwitchParameter>]] [-Platform <String>]
[-SetPropertyValue <String>] [-ThrottleLimit <Int32>] -DriverName <String> -DsnType <String> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


Do not attempt to use Set-OdbcDsn to add a new DSN.


For more information about ODBC, data source names, and drivers, see Microsoft Open Database Connectivity
(ODBC)http://msdn.microsoft.com/en-us/library/ms710252.aspx, Data Sourceshttp://msdn.microsoft.com/en-us/library/ms711688.aspx, and
Drivershttp://msdn.microsoft.com/en-us/library/ms715383.aspx.



<

RELATED LINKS

Get-OdbcDsn
Remove-OdbcDsn
Set-OdbcDsn
N:Wdac



REMARKS

<

Examples




PS C:\> Add-OdbcDsn MyPayroll -DriverName "Microsoft Access Driver (*.mdb, *.accdb)" -DsnType User -Platform 32-bit -SetPropertyValue
'Dbq=C:\mydatabase.accdb'



This command adds a 32-bit ODBC User DSN named as "MyPayroll" using the specified 32-bit driver "Microsoft Access Driver (*.mdb, *.accdb)"
with the specified DBQ properties. The Name parameter is positioned at 0:






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



This command adds the ODBC System DSN(s) named as "MyPayroll" using SQL Server Native Client 10.0 with the specified DSN properties. Please
note that Platform is defaulted to the native platform:






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



This command is equivalent to example 2, but it saves the newly-created System DSN object into a PowerShell variable for future use. By
default, this command does not return the driver object if the "PassThru" parameter is not specified:






C:\PS> $dsnArr = Get-OdbcDsn -DriverName 'SQL Server Native Client 10.0'
C:\PS> foreach ($dsn in $dsnArr) {
Remove-OdbcDsn $dsn
# You can change the property array as well,
# if DSN attributes have been changed in the new driver version

Add-OdbcDsn –Name $dsn.Name -DsnType $dsn.DsnType -Platform $dsn.Platform -DriverName 'SQL Server Native Client 12.0'
-SetPropertyValue $dsn.PropertyValue
}



This command migrates DSNs using the SQL Server Native Client 10.0 driver to a newer version of that driver. This command works for the SQL
Server Native Client ODBC driver.