PowerShell Logo Small

Set-OdbcDsn



This is the built-in help made by Microsoft for the command 'Set-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

Modifies one or more ODBC DSNs. This modifies existing DSNs in the system.

SYNTAX


Set-OdbcDsn [-InputObject] <CimInstance> [-AsJob [<SwitchParameter>]] [-CimSession <CimSession>] [-PassThru [<SwitchParameter>]]
[-RemovePropertyValue <String>] [-SetPropertyValue <String>] [-ThrottleLimit <Int32>] [-Confirm [<SwitchParameter>]] [-WhatIf
[<SwitchParameter>]] [<CommonParameters>]
Set-OdbcDsn [-Name] <String> [-AsJob [<SwitchParameter>]] [-CimSession <CimSession>] [-DriverName <String>] [-PassThru [<SwitchParameter>]]
[-Platform <String>] [-RemovePropertyValue <String>] [-SetPropertyValue <String>] [-ThrottleLimit <Int32>] -DsnType <String> [-Confirm
[<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


Use Add-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

Add-OdbcDsn
Get-OdbcDsn
Remove-OdbcDsn
N:Wdac



REMARKS

<

Examples




PS C:\> Set-OdbcDsn -Name "MyPayroll" -DsnType System -Platform 64-bit -SetPropertyValue "Database=Payroll"



This command changes the 64-bit ODBC System DSN named "MyPayroll" to use a database named as "Payroll" (This example is designed for SQL
Server drivers):






PS C:\> Set-OdbcDsn MyPayroll -DsnType System -SetPropertyValue "Database=Payroll"



This command is similar to the previous example, but it configures a DSN on the native platform (default Platform value):






PS C:\> Set-OdbcDsn -Name "MyPayroll" -DsnType User -Platform 32-bit -RemovePropertyValue @("UID", "PWD") -SetPropertyValue
@("Trusted_Connection=Yes", "Database=Payroll")



This command changes the specified 32-bit ODBC User DSN with name equal to "MyPayroll" from using SQL Authentication to using Windows
Authentication. (This example is designed for SQL Server drivers.) Also, it sets the Database key to "Payroll":






PS C:\> Set-OdbcDsn -Name "*Payroll*" -DsnType All -Platform All -DriverName "Microsoft Access Driver (*.mdb, *.accdb)" -SetPropertyValue
'Dbq=C:\payroll.accdb'



This command changes all ODBC User DSN(s) and System DSN(s) on both platforms with name matching the wildcard "*Payroll*" and that is using a
driver named "Microsoft Access Driver (*.mdb, *.accdb)" to use the database file "C:\payroll.accdb":






PS C:\> Get-OdbcDsn -DriverName "SQL Server*" -DsnType All -Platform All
| Where-Object{ ($_.Attribute["Server"] -eq "oldServer") }
| Set-OdbcDsn -SetPropertyValue "Server=newServer"



This command migrates the oldServer to newServer for all User DSN(s) and System DSN(s) using a driver with name started with "SQL Server":






PS C:\> $sysDsn = Set-OdbcDsn "MyPayroll" -DsnType System -Platform All -SetPropertyValue "Database=Payroll" -PassThru



This command is equivalent to the first example but it also stores the output object in a PowerShell variable. By default, this command does
not return the driver object if the "PassThru" parameter is not specified:






PS C:\> $dsnArray = Get-OdbcDsn -DriverName "SQL Server*" | Where-Object{ ($_.Attribute["Server"] -eq "oldServer") }
Set-OdbcDsn $dsnArray -SetPropertyValue "Server=newServer"



This command migrates the oldServer to newServer for all User DSN(s) and System DSN(s) using a driver with name started with "SQL Server" and
uses the PowerShell variable $dsnArray.