This is the built-in help made by Microsoft for the command 'Add-OdbcDsn', in PowerShell version 5 - as retrieved from
Windows version 'Microsoft Windows Server 2012 R2 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.
Adds an ODBC DSN.
Add-OdbcDsn [-Name] <String> [-AsJob] [-CimSession <CimSession>] [-PassThru] [-Platform <String>] [-SetPropertyValue <String>] [-ThrottleLimit <Int32>] -DriverName <String>
-DsnType <String> [<CommonParameters>]
The Add-OdbcDsn cmdlet adds an Open Database Connectivity (ODBC) data source name (DSN) to the computer. You can specify the properties of the DSN by using the
SetPropertyValue parameter.
Do not use the Set-OdbcDsn cmdlet 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 Sources (http://msdn.microsoft.com/en-us/library/ms711688.aspx), and Drivers (http://msdn.microsoft.com/en-us/library/ms715383.aspx) on the Microsoft Developer Network.
<
Online Version: http://go.microsoft.com/fwlink/p/?linkid=287600
Get-OdbcDsn
Remove-OdbcDsn
Set-OdbcDsn
N:Wdac
<
Example 1: Add a 32-bit ODBC User DSN
PS C:\> Add-OdbcDsn -Name "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 MyPayroll that uses the specified 32-bit driver with the specified properties.
Example 2: Add an ODBC System DSN
PS C:\> Add-OdbcDsn -Name "MyPayroll" -DriverName "SQL Server Native Client 10.0" -DsnType "System" -SetPropertyValue @("Server=MyServer", "Trusted_Connection=Yes",
"Database=Payroll")
This command adds the ODBC System DSNs named MyPayroll that use SQL Server Native Client 10.0 with the specified DSN properties. Because the command does not include the
Platform parameter, the platform architecture is the default, native platform.
Example 3: Add and store an ODBC System DSN
PS C:\> $newDsn = Add-OdbcDsn -Name "MyPayroll" -DriverName "SQL Server Native Client 10.0" -DsnType "System" -SetPropertyValue @("Server=MyServer",
"Trusted_Connection=Yes", "Database=Payroll") -PassThru
This command adds the ODBC System DSNs named MyPayroll that use SQL Server Native Client 10.0 with the specified DSN properties, and then stores the results in the $newDsn
variable. The command includes the PassThru parameter. Without PassThru, the cmdlet does not return anything.
Example 4: Migrates DSNs to a newer version of a driver
PS C:\> $dsnArr = Get-OdbcDsn -DriverName 'SQL Server Native Client 10.0'
PS C:\> foreach ($dsn in $dsnArr) {
Remove-OdbcDsn -InputObject $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 example 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.