If you operate a list of allowed mac addresses on your DHCP server to prevent unauthorised users/devices from obtaining an IP address, it can be a pain to have to constantly open the DHCP console and disable/enable the list and/or add a new device to the list.

To make this easier, you can setup a quick PowerShell script which will manage this for you.

How this DHCP management PowerShell script will help you

When you run the script, it shows you the current status of your filters.

True means that the filter is enabled (only allows devices in the list to obtain IP addresses) and false means that it’s disabled (allow any device to get an IP address).

Then it asks you to select an option from the below:

  • [E] enable – this turns on the filter list and prevents devices that aren’t in the list from getting a dynamic IP address.
  • [D] disable – this turns off the list and allows any device to get a dynamic ip address.
  • [A] add – this allows you to add a new device to the list (requires mac address and device name).

I hope you’ll agree, that this makes DHCP management a lot more efficient and quicker.

Creating a PowerShell script to manage your DHCP filters

Please note that you need administrative rights over the server to manage your DHCP filter lists. With the recent increase in malware attachs, I’d recommend that your account isn’t a domain admin, so I’d recommend running this as another option.  I will produce another article explaining how to do this soon.

To make your own, follow the below easy steps.

  1. Start by creating an empty script file called ‘dhcp_filters.ps1’ and save it somewhere (eg on your desktop).
  2. Open ‘dhcp_filters.ps1’ in a test editor, I like Notepad++.
  3. Copy the below script.
  4. Replace ‘ENTER_SERVER_NAME_HERE’ with the name of your DHCP server.
  5. Save your script.
  6. Now just run the scripts and you can manage your DHCP filter lists more efficiently.

If you have any suggestions on how to improve on this script, please share them in the comments below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here