Set-OdbcDsn change source Name

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

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! :wink:

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: (:slight_smile: [Set-OdbcDsn], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Set-OdbcDsn

Do you get any output when you do

Get-OdbcDsn -Name Data1
?

If the answer is yes you should try

Get-OdbcDsn -Name Data1 | Set-OdbcDsn -SetPropertyValue “Name=Data2”

Are you sure that the name is not read only?