Set-OdbcDsn change source Name

Welcome Forums General PowerShell Q&A Set-OdbcDsn change source Name

Viewing 3 reply threads
  • Author
    Posts
    • #210684
      Participant
      Topics: 1
      Replies: 1
      Points: 14
      Rank: Member

      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

      • This topic was modified 2 months, 2 weeks ago by akurzawa.
      • This topic was modified 2 months, 2 weeks ago by akurzawa.
    • #210693
      Participant
      Topics: 4
      Replies: 2249
      Points: 5,494
      Helping Hand
      Rank: Community MVP

      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! 😉

    • #210759
      Participant
      Topics: 1
      Replies: 1
      Points: 14
      Rank: Member

      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

    • #210771
      Participant
      Topics: 4
      Replies: 2249
      Points: 5,494
      Helping Hand
      Rank: Community MVP

      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?

Viewing 3 reply threads
  • You must be logged in to reply to this topic.