Welcome › Forums › General PowerShell Q&A › Set-OdbcDsn change source Name
- This topic has 3 replies, 2 voices, and was last updated 10 months, 1 week ago by
Participant.
-
AuthorPosts
-
-
March 16, 2020 at 10:15 pm #210684
Hi
I’m struggling to change a name of the ODBC source (mysql odbc name in this case)
PS C:\WINDOWS\system32> Get-OdbcDsn
Name : Store1
DsnType : User
Platform : 32/64-bit
DriverName : MySQL ODBC 3.51 Driver
Attribute : {PORT, DESCRIPTION, SERVER, DATABASE}I’m trying to do it with Set-OdbcDsn but I don’t know how to do it
Set-OdbcDsn -Name “Store1″ -DsnType All -Platform All -SetPropertyValue @{Name=”StoreNew”}
Set-OdbcDsn : Der DSN wurde nicht gefunden.
At line:1 char:1
+ Set-OdbcDsn -Name “Store1” -DsnType All -Platform All -SetPropertyVal …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (MSFT_OdbcDsnTask:Root/Microsoft/…SFT_OdbcDsnTask) [Set-OdbcDsn], CimException
+ FullyQualifiedErrorId : MI RESULT 6,Set-OdbcDsn -
March 16, 2020 at 10:58 pm #210693
Please read the help for Set-OdbcDsn. You should read it completely including the examples to learn hot to use it. Especially the examples #5 and #7! 😉
-
March 17, 2020 at 9:55 am #210759
Get-OdbcDsn -Name Data1
$input = Get-OdbcDsn -Name "Data1" | Where-Object{ ($_.Attribute["Name"] -eq "Data1") }
Set-OdbcDsn -InputObject $input -SetPropertyValue "Name=Data2"Name : Data1
DsnType : User
Platform : 32/64-bit
DriverName : MySQL ODBC 3.51 Driver
Attribute : {PORT, DESCRIPTION, SERVER, DATABASE}Set-OdbcDsn : Cannot validate argument on parameter ‘InputObject’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:5 char:26
+ Set-OdbcDsn -InputObject $input -SetPropertyValue “Name=Data2”
+ ~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-OdbcDsn], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Set-OdbcDsn -
March 17, 2020 at 10:32 am #210771
Do you get any output when you do
PowerShell1Get-OdbcDsn -Name Data1?
If the answer is yes you should try
PowerShell1Get-OdbcDsn -Name Data1 | Set-OdbcDsn -SetPropertyValue "Name=Data2"Are you sure that the name is not read only?
-
-
AuthorPosts
- The topic ‘Set-OdbcDsn change source Name’ is closed to new replies.