Wake up single Computer or collection of Computers in ConfigMgr 1810 using PowerShell

In Configuration Manager a new way of waking up computers exists. We can Wake Up a single computer or all computers in a collection using the Client Notification channel, no need to configure Wake-On-LAN in Configuration Manager site settings and no need to ask the network team to turn on Subnet-Directed Broadcast. We tested it without anything configured as shown below:

The new Wake-Up feature will choose a computer on the same subnet as the computer you want to wake-up and send the magic packet on the local subnet. Simply great! If no other computer is turned on at that subnet, we get a message that no computer can wake-up the device.

This means that we can schedule a PowerShell script to wake a collection of Computers and how cool is that! More on that later in this post.

There is a new client setting that makes it easier to configure Wake-On Lan as well, under Power Management called “Allow network wake-up”

It configures the Network adapter in Windows to allow wake-on-lan as shown below, if we disable the client setting both wake up settings are deselected again.

A common question I have gotten many times are the need to wake computers in a schedule for example for patching. There is a method in WMI in Configuration Manager 1810 that can be used to wake up a single computer or a collection of computers using Powershell for example, which makes it possible to use the new Wake Up feature from a script.

The sample below can handle a single computername as input or a collectionID, Examples:

The script:

# Script to use client notification to Wake up a single computer or a collection of computers.

# Written by Johan Schrewelius and Jörgen Nilsson

# 2019-01-22 ccmexec.com

[CmdletBinding()]

Param(

    $CmpName = $Null,

    $CollId = “SMS00001”,

    $SiteServer = “SCCM01.test.local”

)

if (!$CmpName -and $CollId -eq “SMS00001”) {

    Write-Host “Seems wrong to wake every single computer in the environment, refusing to perform.”

    exit 1

}

$SiteCode = (Get-WmiObject -ComputerName “$SiteServer” -Namespace root\sms -Query ‘SELECT SiteCode FROM SMS_ProviderLocation’).SiteCode

if ($CmpName) {

    $ResourceID = (Get-WmiObject  -ComputerName “$SiteServer” -Namespace “Root\SMS\Site_$($SiteCode)” -Query “Select ResourceID from SMS_R_System Where NetBiosName = ‘$($CmpName)'”).ResourceID

    if ($ResourceID) {

        $CmpName = @($ResourceID)

    }

}

$WMIConnection = [WMICLASS]”\\$SiteServer\Root\SMS\Site_$($SiteCode):SMS_SleepServer”

$Params = $WMIConnection.psbase.GetMethodParameters(“MachinesToWakeup”)

$Params.MachineIDs = $CmpName

$Params.CollectionID  = $CollId

$return = $WMIConnection.psbase.InvokeMethod(“MachinesToWakeup”, $Params, $Null)

if (!$return) {

    Write-Host “No machines are online to wake up selected devices”

}

if ($return.numsleepers -ge 1) {

    Write-Host “The resource selected are scheduled to wake-up as soon as possible”

}

The script can be downloaded here to avoid copy/paste errors: https://bit.ly/2Czvsi3

To verify that it works, the normal WoL log files are not used but the Client Notification log files are so you can check for example BGBMGR.log file that the files are written to clients that will wake the client up.

There is still some configuration that must be done on some HW models in BIOS/Firmware to get Wake-On Lan running.

The new Wake Up option requires little or no network re-configuration which is great! Thanks Johan Schrewelius for a full day of testing!

2 Comments

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.