Set-OdbcDsn
Configures properties for existing ODBC DSNs.
Set-OdbcDsn
[-PassThru]
[-SetPropertyValue <String[]>]
[-RemovePropertyValue <String[]>]
[-InputObject] <CimInstance[]>
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-OdbcDsn
[-PassThru]
[-SetPropertyValue <String[]>]
[-RemovePropertyValue <String[]>]
[-Name] <String>
[-DriverName <String>]
[-Platform <String>]
-DsnType <String>
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
The Set-OdbcDsn cmdlet configures the properties for existing Open Database Connectivity (ODBC) data source names (DSNs). Specify properties to add or modify by using the SetPropertyValue parameter. Specify properties to remove by using the RemovePropertyValue parameter.
Use the Add-OdbcDsn cmdlet to add a new DSN.
For more information about ODBC, data source names, and drivers, see Microsoft Open Database Connectivity (ODBC), Data Sources, and Drivers on the Microsoft Developer Network.
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 Payroll. This example is designed for SQL Server drivers.
PS C:\> Set-OdbcDsn -Name "MyPayroll" -DsnType "System" -SetPropertyValue "Database=Payroll"
This command changes the native platform ODBC System DSN named MyPayroll to use a database named Payroll. This example resembles the previous example, but it does not specify the Platform parameter.Therefore, configures a DSN on the native platform.
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 named MyPayroll from using SQL Server Authentication to using Windows Authentication. This example is designed for SQL Server drivers. Also, the command specifies a value of Payroll for the Database key.
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 DSNs and System DSNs on both platforms with names that contain Payroll and that use 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 DSNs and System DSNs that use a driver that has a name that starts with SQL Server.
PS C:\> $sysDsn = Set-OdbcDsn -Name "MyPayroll" -DsnType "System" -Platform "All" -SetPropertyValue "Database=Payroll" -PassThru
This command changes the 64-bit ODBC System DSN named MyPayroll to use a database named Payroll, and then stores the result in the $sysDsn variable. The command includes the PassThru parameter. Without PassThru, the cmdlet does not return anything.
PS C:\> $DsnArray = Get-OdbcDsn -DriverName "SQL Server*" | Where-Object{ ($_.Attribute["Server"] -eq "oldServer") }
PS C:\> Set-OdbcDsn -InputObject $DsnArray -SetPropertyValue "Server=newServer"
The first command uses the Get-OdbcDsn cmdlet to get each driver that has a name that starts with SQL Server and has a value of oldServer for the Server attribute. The command stores the results in the $DsnArray variable.
The second command sets the value for Server to a new value.
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.
Type: | CimSession[] |
Aliases: | Session |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the name of a driver. This cmdlet modifies the ODBC DSN that uses the driver that this parameter specifies. You can use wildcard characters. If you do not specify this parameter, this cmdlet modifies DSNs for all drivers.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the type of an ODBC DSN. This cmdlet modifies a DSN of the type that this parameter specifies. The acceptable values for this parameter are:
- User
- System
- All
Type: | String |
Accepted values: | User, System, All |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the input object that is used in a pipeline command.
Type: | CimInstance[] |
Aliases: | Dsn |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the name of an ODBC DSN. This cmdlet modifies the DSN that this parameter specifies. You can use wildcard characters to specify more than one ODBC DSN.
Type: | String |
Aliases: | DsnName |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the platform architecture. This cmdlet modifies the ODBC DSN that belongs to the architecture that this parameter specifies. The acceptable values for this parameter are:
- 32-bit
- 64-bit
- All
The default value is 32-bit on a 32-bit process. The default value is 64-bit on a 64-bit process. If you run this cmdlet in a remote CIM session, this parameter refers to the platform architecture on the remote computer.
Type: | String |
Accepted values: | 32-bit, 64-bit, All |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies an array of property values to remove. This cmdlet removes the property values that this parameter specifies from the ODBC DSN. Specify an array of keys to remove.
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies an array of property values. This cmdlet modifies the properties that this parameter specifies for the ODBC DSN. Specify array of strings of the form <key>=<value>.
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the maximum number of concurrent operations that can be established to run the cmdlet.
If this parameter is omitted or a value of 0
is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer.
The throttle limit applies only to the current cmdlet, not to the session or to the computer.
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |