Using Wake-On-Lan to wake a Windows File History network drive

Here is a script I created to automatically wake my QNAP NAS when my laptop is on and trying to save file history. I use it in conjunction with a script to put the NAS back to sleep when idle.

This script can also be used to wake a remote target for any other reason too. It should work for waking any remote target which is configured to Wake-On-Lan (WOL).

Instructions

Download the wol.ps1 script below and place it somewhere accessible on your local drive.
Open the Task Scheduler and navigate to Microsoft -> Windows -> FileHistory.

Right click on the File History (maintenance mode) task and select Properties

Screenshot showing the File History scheduled task details

From the Action tab, choose New and enter the following details:

  • Action: Start a program
  • Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Add arguments: -ExecutionPolicy Bypass -File <wol.ps1 location> -mac <mac address> -ip <ip address> -broadcast <broadcast address>
    For example: -ExecutionPolicy Bypass -File c:\bin\wol.ps1 -mac 11:22:33:44:55:66 -ip 192.168.10.1 -broadcast 192.168.10.255

The broadcast parameter is optional, but if you have multiple network interfaces then it helps to ensure that the WOL magic packet goes out over the right interface.

Press OK and position the new action at the top of the list using the arrows on the right.

Screenshot showing the File History scheduled task actions.

Finally, press OK again to save.

You can test whether the script is working by right clicking on the task and selecting Run. The remote target should wake.

Troubleshooting

If the remote target doesn’t wake, try the following:

  • Try running the script manually using powershell, with the same arguments as provided. The output should give you some clues
  • Double check the mac address and IP address
  • If you have multiple interfaces, consider providing the broadcast address. If you don’t know what this is, try replacing the last segment of your IP address with 255.
  • Enable Task History using the pane on the right of the Task Scheduler window. This should activate the History properties with in the task. From there you can see whether the action succeeded (return code 0) or failed.

Script

Leave a Reply