WOL And Reboot Over Multiple Subnets With SCCM

Running a Wake On LAN can be tricky if you’ve got lots of subnets to worry about. A magic packet will only work in the local subnet unless you happen to have complete access to your entire network and make some router changes.

There’s also ‘Wake Up Proxy‘ which was added to Configuration Manager that can potentially work too as it’s peer to peer and clients try to wake each other up, but won’t work in a lot of scenarios such as 802.1X.

In light of these, I wrote a script that was a mashed up version of a few things I could find and accomplish the task of sending WOL packets to each subnet I cared about.

What this script does:

  • Pulls computers and in turn, MAC addresses from a pre-created SCCM collection.
  • Checks each computer to see if it’s online
  • If online, it will trigger a reboot countdown of 5 minutes, with a warning prompt
  • If offline, it will send a WOL magic packet to the computer

This is valuable to me for software installs that require no user logged onto a computer. It will leave all computers at the login screen, ready for software installs.

This only works in a single subnet though, so the next trick is to set this up on a server in each subnet as a scheduled task. Each server is configured to check the SCCM collection of computers that exist in that subnet. Then, a master task is created that calls the task on each of the other servers:


This master task triggers all the WOL scripts, on a schedule or on demand as you wish. You need to use an account that has access on all servers required of course to be able to remotely trigger the scheduled tasks.

I’ll also note that Adam Bertram wrote a different WOL script that will find each subnet and use any PC it can find to send WOL commands to other computers which is worth checking out. It doesn’t incorporate the forced reboot, but should be modifiable to achieve that result.

The script uses the free wol.exe program from Gammadnye and is expecting to run from C:\Scripts\ but you can change that to whatever you like without breaking anything.

Download the script here (rename to .ps1)


Start-Transcript -path C:\Scripts\Log\wolreboot.txt
$SiteCode = ‘SCCM Site Code goes here’
$CollectionName = ‘Target collection name goes here’
#Retrieve SCCM collection by name
$Collection = GWMI -ComputerName $siteServer -NameSpace “ROOT\SMS\site_$SiteCode” -Class SMS_Collection | where {$_.Name -eq “$CollectionName”}
#Retrieve members of collection
$SMSMembers = GWMI -ComputerName $SiteServer -Namespace “ROOT\SMS\site_$SiteCode” -Query “SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID=’$($Collection.CollectionID)’ order by name” | select Name

ForEach ($SMSMember in $SMSMembers){
If (test-connection $SMSMember.Name -Count 1 -quiet)
write-host $SMSMember.Name “Online”
$name = $smsmember.name
Start-Process Shutdown “-r -t 300 -m \\$name -c `”Initiating scheduled maintenance reboot. You have 5mins to save your before your PC will reboot`”” -NoNewWindow -Wait
$a = (GWMI -ComputerName $siteServer -Class SMS_R_SYSTEM -Namespace root\sms\site_$SiteCode | where {$_.Name -eq $SMSMember.Name}).MACAddresses
$a = $a -replace ‘:’,”
foreach ($mac in $a){

C:\Scripts\\wol.exe $mac
write-host $SMSMember.name “WOL packet sent” $mac
write-host `r`n}


Update 9th August 2016

A few changes to the script – it’ll now log via transcript, but more importantly will support SCCM client objects with multiple MAC addresses, and broadcast each found MAC address.