Previous Section Table of Contents Next Section

Testing the Query

Wbemtest is the place to test my new query. Unfortunately, executing it yields an error: "Invalid object path." Uh-oh.

I'm guessing the problem is that Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration are associated through Win32_Net-workAdapterSetting, which uses Win32_NetworkAdapter.DeviceID and Win32_NetworkAdapterConfiguration.Index to perform the association. In other words, the associator class has no clue about Win32_Network-Adapter.NetConnectionID.

Just to confirm that, I'll retest the query using this.


ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID="1"} WHERE

RESULTCLASS = Win32_NetworkAdapterConfiguration

Sure enough, this query returns the expected instance of Win32_NetworkAdapterConfiguration. Here's what I'm going to have to do.

  • Read a list of computer names from a text file.

  • Connect to WMI on each computer and locate the network adapter named "Local Area Connection."

  • Get the DeviceID from the Win32_NetworkAdapter instances returned.

  • For each instance, query the associated Win32_NetworkAdapterConfiguration instances.

  • For each of those instances, ensure that each configuration for that adapter is set to use DHCP.

I just need to code these actions into a script.

    Previous Section Table of Contents Next Section