Trial #10: Wake on Lan Utility with DHCP Query

2 minute read

Problem:

Wake on LAN for client machines on a domain with c.400 computers using a database of MAC addresses.

Solution:

This post has been almost entirely superseded by a newer post. This post may morph into a tutorial on refactoring or I may just redirect to the newer post.

Wake On LAN or WOL, Using Magic Packets, requires, at the least, knowledge of the target computers Mac Address.

MAC address aren’t particularly human readable and therefore we rarely use them to identify a computer without aid of software. In my case I would like to know a MAC address by a given hostname or a list of MAC address by a given range or site.

To achieve this I first thought to reference an existing collection of MAC address, using a query against a local ARP Cache was discussed but this seemed far more limited than a query against a DHCP server.

A Powershell module called the DhcpServer Module, available on a windows DHCP server (and maybe elsewhere), has some really useful Cmdlets for querying DHCP. I built up an idea how to use them following this Weekend Scripter Blog.

The following is a quick and dirty attempt at combining a DHCP query with an implementation of a Wake on LAN Utility from depicus’ imaginatively called Wake on Lan.

Please don’t presume that the following script is fully tested or developed. A more developed version of the same script can be found at this newer post Improvements include:

Pitfalls

  • Need to initiate Wake on LAN command on a computer on the same Subnet\VLAN as the target computer or utilise a less than completely basic router config (see. Subnet directed broadcasts).

  • I found that this DHCP query only returned relatively recent Leases dependent on the life of the lease this might only be a few hours or days. As such it thought it might struggle to turn on a machine that had been off for a month say during a summer holiday at a school.

  • This script just isn’t finished. It’s not fully developed or tested and I might never complete it as I’m now working on a better one that queries our PDQ Inventory database for a Host’s MAC Address Site(Subnet/Broadcast Address).

Updated: