次の方法で共有


Using Powershell to Update DNS Records on GoDaddy API

I was recently working on using the GoDaddy API in lieu of using dynamicDNS to keep my lab IP up to date.  I stumbled across a post on Stack Overflow where someone had already started some work on this, but had not quite got it working.

I was able to take what they had provided, make a couple of changes, and get it working.  It might help you out to!

https://stackoverflow.com/questions/39123202/error-422-when-using-powershell-to-update-dns-records-on-godaddy-api

Enjoy!

Comments

  • Anonymous
    December 03, 2016
    please share your changes. I found the same post but haven't figured it out.
  • Anonymous
    December 03, 2016
    What did you do to figure it out? I still get the 422...
    • Anonymous
      January 14, 2017
      Looks like they stopped accepting the TTL value (at least for me) in the $Request. I am posting an update now.Thanks!
  • Anonymous
    May 28, 2018
    I struggles with this for a minute also. I was able to get it to work with the following$apiKey = 'YOUR API KEY'$apiSecret = 'YOUR API SECRET'$domain = 'YOUR DOMAIN NAME'#ENTER THE NAME OF THE RECORD YOU WISH TO UPDATE#$name = '@'$Headers = @{}$Headers["Authorization"] = 'sso-key ' + $apiKey + ':' + $apiSecret$result = Invoke-WebRequest https://api.godaddy.com/v1/domains/$domain/records/A/$name -method get -headers $headers$content = ConvertFrom-Json $result.content$dnsIp = $content.data$currentIp = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip#THIS SECTION CHECKS THE CURRENT IP ADDRESS AGAINST THE PULL AND WILL UPDATE IF NOT CORRECT#if ( $currentIp -ne $dnsIp) { #$Request = @{ttl=600;data=$currentIp } $JSON = ConvertTo-Json @(@{data=$currentIp;ttl=600}) Invoke-WebRequest https://api.godaddy.com/v1/domains/$domain/records/A/$name -method put -headers $headers -Body $json -ContentType "application/json" }#SHOWS RESULTS OF THE HEADER PULLInvoke-WebRequest https://api.godaddy.com/v1/domains/$domain/records/ -Method Get -Headers $Headers | ConvertFrom-Json