Did you ever had a situation where you need to urgently deploy something, for example some critical patches due to announced vulnerability/flaw in systems that you’re actively maintaining? Imagine that this needs to be done outside of maintenance window and your machines are sleeping, how are you going to wake up them? Thanks to everyone who invented this good feature – Wake on lan. Most of network cards today are capable of receiving specifically crafted packets that will make computer to wake up from sleep mode, by default this is not enabled, so let’s craft few simple steps to deploy this capability via SCCM task sequence.

1. First let’s create an Powershell script – Microsoft scripting guy Ed Wilson did a great job inspecting WMI methods and classes and gave us ability to enable this feature via PS, code is right below.

$nic = Get-WmiObject -ClassName win32_networkadapter -Filter "netenabled = 'true'" | where {$_.ServiceName -ne "kmloop"}
$nicPower = Get-WmiObject -Namespace root\WMI -ClassName MSPower_DeviceWakeEnable | where {$_.InstanceName -match [regex]::escape($nic.PNPDeviceID)}
$nicPower.Enable = $true
$nicPower.psbase.put()

Once script is written, we should save it on our SCCM or File Server in a source directory – where you usually put source files for your packages – it should look like this;

WOL

2. Once first step is completed, we have to create a package which will contain this script, have to mention that this package should only contain source files – you do not have to create an program from it. Create a package and specify the UNC path to the folder where you saved it.

1.png

Screenshot_2

3. Last step is to create a task sequence, add step – Run Command Line, specify the Package that you created in previous step, after that specify a path to Powershell program and invoke the script that is sent from the package specified, code and picture right below.

%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy bypass -nologo -file Enable-WOL.ps1

 

Screenshot_3

Note: In Hyper-V environments this option doesn’t exist on virtual NICs, while on VMware you will find it, same natively as on every physical computer. In order for this to be a complete process, computer should be restarted, so you can schedule a restart during next maintenance window.

Conclusion: Next time when you push some kind of required deployment to your computers, you will be able to send a wake up packet.

Screenshot_4