Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

Automation Scripts

Reply

Update/modify multiple A records

Posts: 1
171     0

Is there any why that i can modify/update multiple DNS record through Powershell Script?
any other script available can you please provide?.

Re: Update/modify multiple A records

Moderator
Moderator
Posts: 69
172     0

In order to do this in bulk you will need to give it a list or range of IP’s to update in a PowerShell scrip then loop through it and do something like the following:

 

  1. Get the record by the IP and view or some other unique qualifying domain then take the response of the “_ref” field and use it in the second step

// GET

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add("Authorization", " Basic b3A3aW59ZXR0ZWxHNe3Om5Zi5SkE5d3RojGtqcjbnmGse=")

 

$response = Invoke-RestMethod 'https://<Infoblox_appliance_domain_here>/wapi/v<Version>/record:a?ipv4addr=<IP_of_record>&view=default.kevin' -Method 'GET' -Headers $headers

$response | ConvertTo-Json

 

  1. Get the response data and grab the “_ref data”:

//example return data

[

    {

        "_ref": "record:a/ZG5zLmJpbmRfYSQuMjk0LmNvbS56b25lLmRlbW8sdGVtcDEsMTAuMC4wLjE:temp1.demo.zone.com/default.kevin", // This is what you want

        "ipv4addr": "10.0.0.1",

        "name": "temp1.demo.zone.com",

        "view": "default.kevin"

    }

]

 

  1. Update the information you want in this example I’ve updated the comment but it’s up to you. Additionally I used the “_ref” field in the previous call to update the record in the PUT request.

// PUT

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add("Authorization", "Basic b3A3aW59ZXR0ZWxHNe3Om5Zi5SkE5d3RojGtqcjbnmGse=")

$headers.Add("Content-Type", "application/json")

 

//here example of changing comment but you can change any field to the request

$body = "{

`n    `"comment`":`"hello again`"

`n}"

 

$response = Invoke-RestMethod 'https://<Infoblox_appliance_domain_Here>/wapi/v<Version>/record:a/ZG5zLmJpbmRfYSQuMjk0LmNvbS56b25lLmRlbW8sdGVtcDEsMTAuMC4wLjE:temp1.demo.zone.com/default.kevin' -Method 'PUT' -Headers $headers -Body $body

$response | ConvertTo-Json

 

Do note that I’m not a powershell expert so I’ll let you decide on how to loop through the IP’s of the A-records that you want to update. Another way you could do it is to grab all the A records in a network with a API call with powershell then loop through all the returned objects and update every a record with the “_ref”.

Hope this helps.

Kevin Zettel

Showing results for 
Search instead for 
Did you mean: 

Recommended for You