I ran into a weird use case recently where I needed to perform a large-scale WoL for a bunch of lab computers after a scheduled campus-wide power outage. Well, I guess I didn't need to, but the alternative was to have someone run around and press hundreds of power buttons.
I immediately though to use PDQ for this. I was able to build a PDQ Deploy package to wake computers fairly trivially, but then I ran into another issue. Every single computer on the lab computers subnet will be offline. PDQ relies on being able to use another computer on that subnet to relay WoL packets, since it can't be done cross-subnet. If every computer on that subnet is offline, PDQ can't wake them.
So, I had the bright idea to add a virtual NIC to our PDQ server on the lab computers subnet. Surely then PDQ could just send WoL packets directly to those computers without needing to relay the packets through another computer first? Nope, no dice. I asked PDQ support about it and the only way to make that work would be to change the NIC binding order to put the lab computers subnet NIC at the top. That is not ideal for several reasons-- I want my PDQ server to do most of its work from its IP on the servers subnet, and I also want this to be extensible so that it can handle several subnets, not just one. Unless I program something in to dynamically swap NIC binding order (which I very much do not want to do), that is not a viable solution.
So, I decided to build a PowerShell script that just takes a PDQ Inventory report as input and then wakes each computer in the report. The script automatically determines which NIC to send the packets from based on the IP address of the target computer.
The input file needs to have the Computer Name, the MAC Address, and the IP address. Technically the Computer Name is not used for anything other than logging so if you really want to omit it you can, but you will get annoying error messages. The script assumes that you are using the defaults for the field names in PDQ Inventory. If the computer running the script does not have a NIC that resides on the same subnet as the target computer it will log an error and move to the next line. I am running this on my PDQ server but you could run it wherever you want. It can take the CSV file from a UNC path as well so you can set up a PDQ Inventory auto report that runs on a schedule like I am doing. I just have the report filtering to IP addresses on subnets that I want to wake.
If you want to perform the wakes on a schedule just set up a scheduled task that runs this script.
Here is the link to the github repo: https://github.com/jlukenichols/WakeOnLANFromCSV
Please sign in to leave a comment.