Scripting configuration of network parameters, such as IP addresses of primary and secondary WINS or DNS servers and lists of DNS suffixes, was rather cumbersome in Windows NT 4.0.
Windows Management Instrumentation provides a number of ways to collect information about network configuration and manage its parameters, making scripting configuration in Windows 2000 and Windows XP much easier. In the first of a two-part article, Marcin Policht overviews the two main classes in WMI that deal with network adapters.
Without having access to APIs available to programmers, it was necessary to resort to workarounds, such as sequence of SendKey methods calls or direct registry manipulation. The first approach (using SendKey method) was at best time consuming to write and at worst vulnerable at runtime. Anyone changing focus windows during script execution could affect its results in a difficult to predict fashion. Direct registry manipulation was much more reliable and rather easy when dealing with DNS-related parameters, since they resided in specific area of registry. WINS settings, on the other hand, were configured on a per-network adapter basis, so their location varied, depending on number and type of network adapters installed on the computer.
Locating the WINS and DNS configuration information became even more challenging in Windows 2000 and XP. This is because each network interface is assigned a unique identifier in the form of GUID. This GUID is referenced in several places in the registry, and, as the name indicates, it is unique per interface on every single computer. Fortunately, cumbersome workarounds are no longer necessary. Windows Management Instrumentation provides a number of ways that can be used to both collect information about network configuration and manage its parameters.
WMI provides two main classes that deal with network adapters. The first one, called Win32_NetworkAdapter contains the list of the following properties. This, however, is not an exclusive list as it contains only the ones are relevant for our purposes:
Interestingly, the Win32_NetworkAdapter does not contain protocol-related network interface configuration. Information about this configuration, along with methods that allow modifying it, are part of Win32_NetworkAdapterConfiguration class. You might wonder why we bothered with the Win32_NetworkAdapter class at all if all methods required for modifying IP configuration are part of different class. The reason is that Win32_NetworkAdapterConfiguration class properties are typically not sufficient enough to properly identify network interface for which you want to modify network configuration. Instead, it is easier to accomplish this using Win32_NetworkAdapter class.
Fortunately, instances of both classes are linked to each other through so-called association. We will use this association to first identify the target network interface using properties of Win32_NetworkAdapter class and then to configure its IP protocol properties with methods applied to corresponding instances of the Win32_NetworkAdapterConfiguration class. To identify the target network interface, we will use one or more of the properties listed above.
We will start with a script that will query information on configuration of computer network adapters. This will allow you to review values of Win32_NetworkAdapter properties of network interfaces. The script enumerates all instances of Win32_NetworkAdapter class, and, for each, it lists all of the properties and their values (or if the property is empty, it displays the message that the property is not set). If the property is an array, all of its elements are listed. A list of the properties for each instance is separated by a double horizontal line. Before launching the script, set the value of sComputer variable to the name of the target computer for which you want to list the property values.
|
You can use the same script to lists all instances of Win32_NetworkAdapterConfiguration class (or any class for that matter) by simply changing the value of sClass variable. Better understanding of actual values of proprieties for each class will help you use more efficiently the scripts modifying WINS and DNS configuration, which be presented and further explained in the next article in this series.
Discuss WMI and other Windows 2000 issues in the ServerWatch Discussion Forum.
Marcin Policht obtained his Master of Computer Science degree about 20 years ago and has been since then working in the Information Technology field, handling variety of responsibilities, but focusing primarily on the areas of identity and access management, virtualization, system management, and, more recently private, hybrid, and public cloud services. He has authored the first book dedicated to Windows Management Instrumentation and co-written several others dealing with subjects ranging from core operating system features to high-availability solutions. His articles have been published on such Web sites as ServerWatch.com and DatabaseJournal.com. For his contributions to the Microsoft technical community, he has been awarded the title of Microsoft MVP over the last ten years.
Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved
Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.