Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Intune
  • GitHub
  • Windows 11
  • About the author
CCMEXEC.COM – Enterprise Mobility

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

Posted on January 22, 2019October 1, 2020 by Jörgen Nilsson

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://github.com/Ccmexec/PowerShell

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!

  • 1810
  • Powershell
  • Wake-On-Lan
  • WakeUP
  • 9 thoughts on “Wake up single Computer or collection of Computers in ConfigMgr 1810 using PowerShell”

    1. Carl says:
      January 22, 2019 at 10:59 am

      Great post, thanks for sharing the information 😉

      Reply
    2. Pingback: ICYMI: PowerShell Week of 25-January-2019 | PowerShell.org
    3. Sam says:
      April 2, 2019 at 12:25 am

      Amazing, I had tried getting this working but missed the fact you have to pass the CollectionID – doh!

      Thanks for the post!

      Reply
    4. Kevin says:
      March 20, 2020 at 3:37 pm

      Running MECM 1910
      Scratching my head. Try to figure out how to fix: Exception calling “InvokeMethod” with “3” argument(s): “Generic failure ” at filepath\filename
      $return = $WMIConnection.psbase.InvokeMethod(“MachinesToWakeup”, $Par …

      Are you seeing this?

      Reply
    5. Kevin says:
      March 24, 2020 at 8:15 pm

      The script works great for me.
      What permissions do I need to provide a user. I have a user running this as admin on there local domain computer but returning an error.
      I did create a security role with Notify resource under the Collection category. A Collection “All System”

      Reply
    6. Chris says:
      April 23, 2020 at 1:51 pm

      Hi!

      I am a network engineer, I have implemented large scale (16000 computers) WoL working with Dot1X.
      We got it working fine with all normal WoL-clients where you can specify broadcast-addresses, but NOT with Microsofts Wakeup in CM.
      This is because apperently, MS has hardcoded the broadcast address (how stupid is that?) and it is not possible to change the broadcast address ANYWHERE in the configuration in MS CM?

      When our computers are sleeping they goto another VLAN. I could fix this whole issue with Wakeup in CM – if only Microsoft allowed me to change the broadcast address in the WoL-packet and use 255.255.255.255 instead.

      Does anyone know if “Wakeup” from CM is hardcoded or if any script is used? If so, where can I edit the script?

      Thanks!

      /Chris

      Reply
    7. Adam says:
      October 1, 2020 at 3:00 pm

      I have the same error:
      “InvokeMethod” with “3” argument(s): “Generic failure ”
      $return = $WMIConnection.psbase.InvokeMethod(“MachinesToWakeup”, $Par …
      CategotyInfo : NotSpecified: (:) []. MethodInvocationException

      any fix?

      Reply
    8. Dak A says:
      November 10, 2020 at 9:54 pm

      Adam:
      The most common cause of that for me has been incorrectly formatted information in one of the parameters. AKA I use a hash table to convert the collection name to the collection number, so I don’t have to remember the collection code. If that doesn’t work and the collection name gets into the $Params.CollectionID parameter, it will throw that error. Or if the computer name, rather than the resource ID, is making it into the $Params.MachineIDs spot.

      Reply
    9. Pingback: [SOLVED] Powershell script to send WoL via SCCM – BugsFixing

    Leave a Reply Cancel reply

    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.

    My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
    All code is provided "AS-IS" with no warranties.

    Tweets by ccmexec

    Recent Posts

    • Windows Servicing, Personal Teams and Success.cmd
    • Windows MDM Security Baseline – Settings Catalog
    • Configuring MS Edge Security Baseline v107 using Settings Catalog
    • Configuring Desktop App Installer using CSP and script?!
    • Customizing Taskbar and Start in Windows 11 22h2 with PowerShell

    ©2023 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
    This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
    Privacy & Cookies Policy

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
    Necessary
    Always Enabled
    Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
    Non-necessary
    Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
    SAVE & ACCEPT