Jump to content

Recommended Posts

Posted

Hey folks!

 

I need some pointers / guidance / solutions / anything, this WOL thing is really bustin my n*ts.

 

In an attempt to get on the 'Green IT' bandwagon, I'm looking at the possibility of shutting machines down every evening and waking them early in the morning, ready for use. I spent 3 days auditing the networking hardware across the domain, considering what NICs are WOL capable and which aren't. So, the ones that are WOL capable, are sorted in the BIOS. However, I find that the there is a particular setting in the Advanced Settings tab of the device properties that is really ruining my day. I tried the following script (which I picked up from another post here), to use WMI to 'theoretically' enable the settings that Power Management needs to get things moving....

 

Option Explicit

Dim colNetworkAdapters
Dim objNetworkAdapter

Dim strDevInstanceName
Dim strNetworkAdapterID

'Query for all of the Win32_NetworkAdapters that are wired Ethernet (AdapterTypeId=0 corresponds to Ethernet 802.3)
Set colNetworkAdapters = GetObject("WinMgmts:{impersonationLevel=impersonate, (LoadDriver)}//./root/Cimv2")_
.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE AdapterTypeId=0")

WScript.Echo "Enabling WoL for the following adapters:"

For Each objNetworkAdapter In colNetworkAdapters
           WScript.Echo "  " & objNetworkAdapter.Name & " [" & objNetworkAdapter.MACAddress & "]"

           strNetworkAdapterID = UCase(objNetworkAdapter.PNPDeviceID)

           'Query for all of the MSPower_DeviceWakeEnable classes
           Dim colPowerWakeEnables
           Dim objPowerWakeEnable

           Set colPowerWakeEnables = GetObject("WinMgmts:{impersonationLevel=impersonate, (LoadDriver)}//./root/wmi")_
           .ExecQuery("SELECT * FROM MSPower_DeviceWakeEnable")
           'Compare the PNP Device ID from the network adapter against the MSPower_DeviceEnabled instances
           For Each objPowerWakeEnable In colPowerWakeEnables
                       'We have to compare the leftmost part as MSPower_DeviceEnabled.InstanceName contains an instance suffix
                       strDevInstanceName = UCase(Left(objPowerWakeEnable.InstanceName, Len(strNetworkAdapterID)))
                       'Match found, enable WOL
                       If StrComp(strDevInstanceName, strNetworkAdapterID)=0 Then
                                   objPowerWakeEnable.Enable = True
                                   objPowerWakeEnable.Put_           'Required to write the value back to the object
		WScript.Echo "Found MSPower Class...Wake enable set."
                       End     If
           Next
           'Query for all of the MSNdis_DeviceWakeOnMagicPacketOnly classes
           Dim colMagicPacketOnlys
           Dim objMagicPacketOnly
           Set colMagicPacketOnlys = GetObject("WinMgmts:{impersonationLevel=impersonate, (LoadDriver)}//./root/wmi")_
           .ExecQuery("SELECT * FROM MSNdis_DeviceWakeOnMagicPacketOnly")
           'Compare the PNP Device ID from the network adapter against the MSNdis_DeviceWakeOnMagicPacketOnly instances
           For Each objMagicPacketOnly In colMagicPacketOnlys
                       'We have to compare the leftmost part as MSNdis_DeviceWakeOnMagicPacketOnly.InstanceName contains an instance suffix
                       strDevInstanceName = UCase(Left(objMagicPacketOnly.InstanceName, Len(strNetworkAdapterID)))
                       'Match found, enable WOL for Magic Packets only
                       If StrComp(strDevInstanceName, strNetworkAdapterID)=0 Then
                                   objMagicPacketOnly.EnableWakeOnMagicPacketOnly = True  'Set to false if you wish to wake on magic packets AND wake patterns
                                   objMagicPacketOnly.Put_             'Required to write the value back to the object
		WScript.Echo "Found Magic Packet Class...Wake enable set."
                       End     If
           Next
Next

 

However, after much local and remote testing, the script doesn't do anything to enable WOL. I have narrowed it down to one or two settings on the Advanced Settings tab of the device properties.

 

advNICproperties.jpg

 

The problem is, this setting needs applied across 100 or so machines (in addition to any new machines that are rebuilt/imaged). Can anyone advise me on how to change this setting programatically, across the domain?

 

Any help, ideas, anything! as always, very much appreciated.

Posted

not going to help you here but if a member of staff/student just turns the pc off by the button and the pc hasn't gracefully shutdown then it won't wol

 

but we use the built in parts to fog which does all this including the shutdown. One thing you need to bear in mind is that a simply shutdown -f -s -m \\machinename will not take into account if a user is still logged in - meaning they could lose work. Whereas fog will only shut the pc down if nobody is logged in.

 

We therefor have a scheduled shutdown at 4pm - 430pm, 5pm, 6pm and 7pm. therefore more of a chance of shutting all pc's down.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...