Let’s build a Infoblox PowerShell Module!

If you haven’t heard of it, Infoblox is making appliances and solutions for enterprise networks. One of them is the Infoblox Trinzic DDI which manages DNS, DHCP and IPAM.

Infoblox does not seem to have any plans for delivering a PowerShell module for managing their product, which is a bit weird since it would probably make it a bit easier for network admins trying to move windows engineers away from Active Directory Integrated DNS, and instead let the Infoblox appliance host all or some of their zones (which seems to be a common enough debate among enterprises).
But in their defence they have released a REST-based API for this appliance which enables administrators to basically build whatever tools they want to manage anything from DNS records to IPAM.

I’ve therefore started to build a module for managing DNS-records hosted by the Infoblox, but since my experience with this product is fairly limited, I thought I would post what I’ve done so far to get opinions from people with more experience with this product.

I’ve only done a few cmdlets (advanced functions) for managing a few common DNS record tasks. So far these are:

  • Add-IBResourceRecordA
  • Add-IBResourceRecordCName
  • Add-IBResourceRecordHost
  • Get-IBResourceRecord
  • Remove-IBResourceRecord
  • Set-IBResourceRecord

Some usage examples:

# Adding a A-record
Add-IBResourceRecordA -IPv4Address 1.2.3.4 -HostName myhost.contoso.com -GridServer $MyInfobloxGrid -Credential $MyCredential

# Adding a hundred A-records
1..100 | % { Add-IBResourceRecordA -IPv4Address 1.2.3.$_ -HostName myhost$_.contoso.com -GridServer $MyInfobloxGrid -Credential $MyCredential }

# Searching for those records
Get-IBResourceRecord -RecordType A -RecordValue myhost* -GridServer $MyInfobloxGrid -Credential $MyCredential

# Search for a record by IP-address
Get-IBResourceRecord -RecordType A -SearchField ipv4addr -RecordValue 1.2.3.4 -GridServer $MyInfobloxGrid -Credential $MyCredential

# Removing all of them
Get-IBResourceRecord -RecordType A -RecordValue myhost* -GridServer $MyInfobloxGrid -Credential $MyCredential -Passthrough | Remove-IBResourceRecord

# Add a HOST record
Add-IBResourceRecordHost -IPv4Address 1.2.3.4 -HostName myhost.contoso.com -GridServer $MyInfobloxGrid -Credential $MyCredential

# Change the IP-address of that record (A-record needs some tweaking before they work, I'm working on it...)
Get-IBResourceRecord -RecordType Host -RecordValue myhost.contoso.com -GridServer $MyInfobloxGrid -Credential $MyCredential -Passthrough | Set-IBResourceRecord -IPv4Address 4.3.2.1

# Add a CName
Add-IBResourceRecordCName -HostName cname.contoso.com  -Canonical myhost2.contoso.com -GridServer $MyInfobloxGrid -Credential $MyCredential

Screenshot:
Infoblox module in action...

This is very early in the development of this module, so it probably have a few bugs, and there are a lot of cmdlets that needs to be written!

Anyone out there that wants help or have any thoughts?

Please post a comment here or join this thread in the Infoblox community forum.

The code for this early version of the module is available at the Github repo!

9 thoughts on “Let’s build a Infoblox PowerShell Module!

  1. Jeff Patton

    I’d be interested in helping you out, I don’t have one of these appliances though. do you have a repo somewhere outside of poshcode?

    Reply
  2. Ross

    Having trouble interacting with objects, get the following error:

    $test = Get-IBResourceRecord -RecordType Host -RecordValue ‘server.domain.subdomain’ -GridServer ‘dns.nml.com’ -Credential $dnsCreds
    if([string]::IsNullOrEmpty($test)){}else{

    Get-IBResourceRecord -RecordType Host -RecordValue ‘server.domain.subdomain’ -GridServer ‘dns.nml.com’ -Credential $dnsCreds | Set-IBResourceRecord -HostName ‘server.domain.subdomain’ -IPv4Address “172.30.221.17”

    }
    DEBUG: https://dns.nml.com/wapi/v1.4.2/record:host?name~=server.domain.subdomain
    DEBUG: https://dns.nml.com/wapi/v1.4.2/record:host?name~=server.domain.subdomain
    DEBUG: https://@{_ref=record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5ubWZjby5ubXRlc3QubnRhZGRoMDA3NW0wMA:server.domain.subdomain.com/Internal; ipv4addrs=System.Object[]; name=server.domain.subdomain; view=Internal}/wapi/v1.4.2/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5ubWZjby5ubXRlc3QubnRhZGRoMDA3NW0wMA:server.domain.subdomain/Internal
    DEBUG: {
    “ipv4addrs”: [
    {
    “ipv4addr”: “172.30.221.17”
    }
    ]
    }
    Invoke-WebRequest : Cannot bind parameter ‘Uri’. Cannot convert value
    “https://@{_ref=record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5ubWZjby5ubXRlc3QubnRhZGRoMDA3NW0wMA:server.domain.subdomain/Internal; ipv4addrs=System.Object[];
    name=server.domain.subdomain; view=Internal}/wapi/v1.4.2/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5ubWZjby5ubXRlc3QubnRhZGRoMDA3NW0wMA:server.domain.subdomain/Internal” to
    type “System.Uri”. Error: “Invalid URI: The hostname could not be parsed.”
    At line:59 char:46
    + $WebReqeust = Invoke-WebRequest -Uri $InfobloxURI -Method Put -Body $Dat …
    + ~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

    Set-IBResourceRecord : Request to Infoblox failed!
    At line:4 char:139
    + Get-IBResourceRecord -RecordType Host -RecordValue ‘server.domain.subdomain …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-IBResourceRecord

    Reply
    1. Anders Post author

      Hi, thanks for reading and commenting.

      I’ve sent you an e-mail with a few things that you can try, but you should also try to add the “-Passthrough” switch to the
      Get-IBResourceRecord function, otherwise the gridserver and credential wont get passed along to the Set-IBResourceRecord function.

      I hope you’ll get it working! And that I will have the oportunity to continue this project sometime! 🙂

      These functions need a lot of polishing!

      Reply
  3. Jeremy Murrah

    Not sure if you’re still working on this, but I’ve been playing around with powershell 5 and the new classes feature, and have started putting together a set of cmdlets that use class definitions for the record types and various methods for the heavy lifting (new, set, delete, etc.).

    It’s not entirely useful yet as version 5 is still in preview, but so far it seems to have some pretty interesting advantages over just cmdlets. Let me know if you’d like to check it out. I’m a github noob, but could probably figure it out if you want me to throw it up there.

    Reply
    1. Anders Post author

      Sounds interesting! This project have been pretty stale for a while now since I don’t work in an environment that is using Infoblox, and haven’t had any people volunteering to work on this module (I have seen examples of people starting new projects regarding it though). I’d love to finish this if I had the time, but since I’m not in the need for it myself anymore I really need to share the workload with someone for it to make sense to finish it. Time is sadly a limited resource… 🙂

      Anyway… Would be interesting to take a look at your code, if you want others to help writing it, Github is a good place to use, if you just want to share what you have, pastebin/poshcode/etc. works as well 🙂

      Thanks for taking the time to comment and share!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *