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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function Set-WakeEnabled
{
<#
.SYNOPSIS

Set WoL on nic

Author: Jan-Henrik Damaschke (@jandamaschke)
License: BSD 3-Clause
Required Dependencies: None
Optional Dependencies: None

.DESCRIPTION

Set Wake on Lan (WOL) settings for specific network interface card

.PARAMETER InterfaceName

Specifies the name of the interface where WoL setting should be changed

.PARAMETER WakeEnabled

Specifies if WoL should be enabled or disabled

.EXAMPLE

PS C:\> Set-WakeEnabled -InterfaceName Ethernet -WakeEnabled $true

.LINK

http://itinsights.org/
#>

[CmdletBinding()] Param(
[Parameter(Mandatory = $True, ParameterSetName="InterfaceName")]
[String]
$InterfaceName,

[Parameter(Mandatory = $True)]
[String]
$WakeEnabled,

[Parameter(Mandatory = $True, ParameterSetName="ConnectionID")]
[String]
$NetConnectionID
)

If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
Break
}

$nicsWakeEnabled = Get-CimInstance -ClassName MSPower_DeviceWakeEnable -Namespace root/wmi
$nics = Get-CimInstance -ClassName Win32_NetworkAdapter | Where-Object NetEnabled -eq $true

if ($InterfaceName){
$nic = $nics | Where-Object Name -eq $InterfaceName
}
else {
$nic = $nics | Where-Object NetConnectionID -eq $NetConnectionID
}

$nicWakeEnabled = $nicsWakeEnabled | Where-Object InstanceName -like "*$($nic.PNPDeviceID)*"

$enabled = $nicWakeEnabled.Enable

if (!($enabled -and $WakeEnabled)){
Set-CimInstance $nicWakeEnabled -Property @{Enable=$enabled}
}
}

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 ;).