Created
October 7, 2014 18:27
-
-
Save shaneramey/13f17acc6f640f1f94df to your computer and use it in GitHub Desktop.
Using Subnet-Directed Broadcasts in SCCM WOL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here’s a method to add a menu within the SCCM Console and remote-wake (WOL) computers on non-local subnets using subnet-directed broadcasts and mc-wol.exe. | |
1) Download and install the SCCM Console Extensions (google it; the download link may change with new versions) and mc-wol.exe (http://www.matcode.com/wol.htm). Put mc-wol.exe in C:\Program Files (x86)\SCCMConsoleExtensions\ | |
2) Edit C:\Program Files (x86)\SCCMConsoleExtensions\SCCMAction.vbs, in the Wake On LAN section, to use the mc-wol.exe program you downloaded. This code gets a list of interfaces, and sends a WOL packet to the broadcast address of each interface calculated by its IP address and Netmask. | |
Be sure to allow subnet-directed broadcasts on your routers. I thank the original author of the console extensions for his/her original code. I added some variables and changed how others are calculated. | |
‘============ | |
‘ Wake On LAN | |
‘============ | |
Sub WakeOnLAN | |
On Error Resume Next | |
Set objSMSWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & strSiteServer & “\” & strNameSpace) | |
Set result = objSMSWMIService.ExecQuery(“SELECT * FROM SMS_G_System_NETWORK_ADAPTER_CONFIGURATION WHERE ResourceID=’” & strResourceID & “‘ AND IPAddress IS NOT NULL”) | |
For Each instance in result | |
strMACAddress = instance.MACAddress | |
strIPAddress = instance.IPAddress | |
strIPSubnet = instance.IPSubnet | |
ipAddressBytes = “” | |
subnetMaskBytes = “” | |
ipAddressBytes = Split(strIPAddress, “.”) | |
subnetMaskBytes = Split(strIPSubnet, “.”) | |
broadcastAddress = (ipAddressBytes(0) Or (subnetMaskBytes(0) Xor 255)) & “.” & (ipAddressBytes(1) Or (subnetMaskBytes(1) Xor 255)) & “.” & (ipAddressBytes(2) Or (subnetMaskBytes(2) Xor 255)) & “.” & (ipAddressBytes(3) Or (subnetMaskBytes(3) Xor 255)) | |
strCmdLine = “\\server\SMS_AA1\bin\i386\mc-wol.exe ” & strMACAddress & ” /a ” & broadcastAddress | |
WshShell.Run strCmdLine,True | |
MsgBox(“Ran ” & strCmdLine) | |
Next | |
WScript.Quit | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment