Reserving DHCP addresses and more with Powershell

Edit: 14 July 2014

Oh dear…I  have learnt so much since this post I’m almost ashamed to have posted this one…No Powershell best practices followed at all in my script and I sincerely suggest you don’t use this!  I’ve left the post up as an example of how not to do it.   Oh well….Here’s the original post…

We are currently using two 2008R2 DHCP servers in my work environment with each one in a different geographical location.

Because of this, a long time ago we set up redundancy between the two so that if one DHCP server was down, the clients at the downed site could continue to receive DHCP addresses and their reserved addresses.

This configuration requires us to make the reservation on both DHCP servers thus duplicating the time and work involved.

In a previous post I toyed around with creating a powershell script with a GUI front-end.  This was fun and will be useful for scripts that I write that non-I.T end-users will use.

I have expanded on what the gui version achieved and wrote a menu system (non-gui) with a few more options and full error checking.  This was surprisingly quick to write.  I have written it so that it pulls the correct scope based on the IP address of the reservation – so it’s one less input for the end user to use.

Here’s a screen-shot:

DHCPReservator

The code has been written so that it can be useful whether you have a single DHCP server or multiple servers.  All you need to do is go to the very bottom of the script and add your domain and DHCP servers to the right variables.  It’s all documented with examples right where you need to do it.

You can download the script here.

Be the first to comment

Leave a Reply