Is it Power Management or Power Mis-Management?

So I hear a lot of complaints about network cards getting shut off when users leave their systems for a while.  This apparently drives our local branch techs a little crazy (who can blame them!) so I needed to find a command to add to our imaging process that would fix this issue post deployment.  Unfortunately it can’t be fixed on the image if your are using Sysprep and Mini-Setup to detect and install software drivers.  We use a single image with MDT 2010 and WDS to deploy to over 12 different models. So, while this script looks pretty simple it was a royal pain in my butt to find the solution, then only 15 minutes to write and test.  Oh well.  : /

Set NetworkAdapters = GetObject("WinMgmts://./root/Cimv2")._
ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE AdapterTypeId=0")
For Each NetworkAdapter in NetworkAdapters
  NetworkAdapterID = UCase(NetworkAdapter.PNPDeviceID)
  Set DevPwrMgtSettings = GetObject("winmgmts://./root/WMI")._
  For Each DevPwrMgtSetting in DevPwrMgtSettings
    DeviceID = UCase(Left_
    (DevPwrMgtSetting.InstanceName, Len(NetworkAdapterID)))
    If NetworkAdapterID = DeviceID Then
    End If

So, breaking it down: First we get a list of network adapters [Set NetworkAdapters = GetObject(“WinMgmts://./root/Cimv2”).ExecQuery(“SELECT * FROM Win32_NetworkAdapter WHERE AdapterTypeId=0”)]. The AdapterTypeID property is used to select only ethernet adapters. Then we pull the PnPID of the adapter [NetworkAdapterID = UCase(NetworkAdapter.PNPDeviceID)] as this is how the MSPower WMI provider identifies devices. Next build our collection of devices MSPower can access [Set DevPwrMgtSettings = GetObject(“winmgmts://./root/WMI”).InstancesOf(“MSPower_DeviceEnable”,48)]. Then we make the InstanceName property of the MSPower object comparable to the NIC PnPID [DeviceID = UCase(Left(DevPwrMgtSetting.InstanceName, Len(NetworkAdapterID)))]. To make sure we are changing the power management setting on a network adapter and not some other device (USB hub, whatever) we compare the PnPID and InstanceName [If NetworkAdapterID = DeviceID Then] and then do the real work, turning off power management [DevPwrMgtSetting.Enable=False]. The final command [DevPwrMgtSetting.Put_] is extremely important, because without it your setting will not be saved!

Now save this script to a .VBS file and run it using cscript.exe: cscript \.vbs

And that’s it, how to easily turn the Power Management settings on your network adapter off (and on if you change the false to true). It is also possible to manage other settings like WOL using some other components of the MSPower WMI provider.


Windows 7

First I suppose I should say I am the world’s worst blogger.  I have just been so busy I haven’t written anything in months.  I know people have been here because I have 2000 or so hits, but no one suggests what they might like to know about.  : (
I have been running Windows 7 at work for months, and today I got my official Windows 7 Ultimate to use at home.  The install process was great and in about an hour I was surfing the web and Facebooking.  So far I can find no complaints.  I think it runs faster than Vista, I love the new Taskbar, and I haven’t found any of my apps to have issues.  I have installed Office 2007, configured my email, and run the apps.  Everything opened very fast and seemed to work as usual.  I look forward to finding some new things to try over the next few weeks.
Oh, and I love the Porsche theme I downloaded from Microsoft.  : )

Uknown Devices got you down?

A handy trick is to right-click the unknown device in Device Manager, then go to Properties.  Click on the Details tab and make that Hardware IDs is selected.  You should see something like:
The red text is the Vendor ID (preceded by VEN_) and the orange text is the Device ID (preceded by DEV_).
Armed with this info you can visit and do a little searching.  I have found a few newer devices that don’t exist there, in which case you can plug both IDs into Google and let the magic begin!