With every recent Windows 10 update, and they happen a lot, Windows unfortunately also resets the power settings of the network adapters. Since I like to start both my PC and notebook from a remote location or from within the same network, I wrote a little PowerShell function to enable Wake-on-LAN (WoL) again.

At first we need the current instances of the MSPower_DeviceWakeEnable class and load them into the $nicsWakeEnabled variable. Next, we get a list of NIC objects with the PNPDeviceID property by getting the instances of Win32_NetworkAdapter (Get-Netadapter doesn’t list the PNPDeviceID field).
Now we just check, if the NIC already has the designated status, given by parameter and if not, setting it by using the Set-CimInstance cmdlet.

For the matching, we have to use the -like operator, as there is an additional number suffix (normally _0) in the InstanceName field of the MSPower_DeviceWakeEnable instances.

Set-WakeEnabled.ps1link
1
function Set-WakeEnabled
2
{
3
<#
4
.SYNOPSIS
5
6
Set WoL on nic
7
8
Author: Jan-Henrik Damaschke (@jandamaschke)
9
License: BSD 3-Clause
10
Required Dependencies: None
11
Optional Dependencies: None
12
13
.DESCRIPTION
14
15
Set Wake on Lan (WOL) settings for specific network interface card
16
17
.PARAMETER InterfaceName
18
19
Specifies the name of the interface where WoL setting should be changed
20
21
.PARAMETER WakeEnabled
22
23
Specifies if WoL should be enabled or disabled
24
25
.EXAMPLE
26
27
PS C:\> Set-WakeEnabled -InterfaceName Ethernet -WakeEnabled $true
28
29
.LINK
30
31
http://itinsights.org/
32
#>
33
34
[CmdletBinding()] Param(
35
        [Parameter(Mandatory = $True, ParameterSetName="InterfaceName")]
36
        [String]
37
        $InterfaceName,
38
39
        [Parameter(Mandatory = $True)]
40
        [String]
41
        $WakeEnabled,
42
43
        [Parameter(Mandatory = $True, ParameterSetName="ConnectionID")]
44
        [String]
45
        $NetConnectionID
46
)
47
48
    If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
49
        Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
50
        Break
51
    }
52
53
    $nicsWakeEnabled = Get-CimInstance -ClassName MSPower_DeviceWakeEnable -Namespace root/wmi
54
    $nics = Get-CimInstance -ClassName Win32_NetworkAdapter | Where-Object NetEnabled -eq $true
55
56
    if ($InterfaceName){
57
        $nic = $nics | Where-Object Name -eq $InterfaceName
58
    }
59
    else {
60
        $nic = $nics | Where-Object NetConnectionID -eq $NetConnectionID
61
    }
62
63
    $nicWakeEnabled = $nicsWakeEnabled | Where-Object InstanceName -like "*$($nic.PNPDeviceID)*"
64
    
65
    $enabled = $nicWakeEnabled.Enable
66
67
    if (!($enabled -and $WakeEnabled)){
68
        Set-CimInstance $nicWakeEnabled -Property @{Enable=$enabled}
69
    }
70
}

After performing the above steps we should be able to see the results directly in the CIM class and in the device manager (devmgmt.msc). If there’s another update, just run the cmdlet with the desired WakeEnabled parameter let your devices wake up via magic packet ;).