Do you find the Support WebCast transcripts helpful?
Let us know!
Microsoft Support WebCast
WMIC: A New Approach to Managing Windows Infrastructure
from a Command Line
July 24, 2002
Note This document is based on the original spoken WebCast transcript. It has been edited for clarity.
Arkady Retik: Thank you for joining us and hello to everyone. My name is Arkady Retik, and the topic of my talk is the WMI command-line tool, which is a new user interface to the Microsoft® Windows® Management Infrastructure. This is a very powerful tool and one of the most exciting new developments in the command-line area in the last years. This talk is focused for the Windows administrator, but it will also be beneficial to developers of management applications.
The main objectives of my talk today (slide 2) are to briefly review the WMI command-line utility and its architecture, to demonstrate the two modes of WMICs operation (note, we pronounce WMIC as "wee-mek"), and to introduce the listener to the advanced uses of WMIC.
After a brief background (slide 3), I will review the WMIC architecture. Then I will follow with a couple of examples of both basic and advanced uses for WMIC commands. Finally, I will explain how you can extend and customize WMIC.
What is WMIC? If we want to define it using one sentence (slide 4), WMIC is a command-line tool that allows you to access various sources of management data through WMI without programming. As I have mentioned earlier, WMIC is a new tool. It's only available on Microsoft Windows XP Professional, and it will soon be on all Windows .NET Server family products.
Who are the WMIC customers or the main users (slide 5)? First of all, these are IT administrators, who will find WMIC is a very useful addition to the various Windows-based graphical user interfaces, especially for automation and remoting while dealing with mountable computers.
Second, any non-programmer who is interested in accessing and exploring the Windows Management Infrastructure will find it easy to do so using WMIC, and probably less boring than just reading documentation.
Finally, being a user interface to WMI, WMIC will be useful to IT groups, public support services, and many others. The main value of WMIC to all users will be in user-intuitive aliases or friendly names. Also, simple ad hoc access is available to the instrumentation, and there is a unique possibility to expand and customize WMIC itself. However, one has to remember that WMIC is still a command-line tool. It does not cover many other areas that an IT administrator needs to deal with.
To summarize the introduction, I would like to quote from an e-mail I have received recently from one IT administrator (slide 6), who wrote:
In fact, I think that WMIC is one of the best tools that came out in the recent years, just because it gives you the power of WMI without being a developer. Not everybody in my team is familiar with Windows Scripting Host, with VBScript, and WMI, so writing scripts that leverage WMI to manage Windows servers could not be done by anybody. With WMIC, they can, without knowing too much about WMI itself just great
Before going into WMIC details, it's important to understand where this utility fits within the variety of management tools available for Windows XP and Windows .NET Server products. As you can see from this picture (slide 7), there are many tools available to support and write a spectrum of tasks, from headless installation (on the left of the slide) for out-of-band computers, to automation and policy setting (on the right of the slide). Being focused on IT professionals, WMIC not only provides the point of contact for getting required information, it also simplifies remote management of network domains.
WMIC was developed as part of the command-line tools program (slide 8). This program provided many simple peripheral utilities, which simplify most of the administration tasks. WMIC added power and extensibility by exposing virtually all management data available, and by allowing you to "roll your own" tasks versus using prebuilt tools.
A couple of words about WMI itself (slide 9). WMI stands for Windows Management Instrumentation, and I guess you figured this out already, it's a Windows-based implementation of WBEM, or the Web-based Enterprise Management initiative. WMI relies on a CIM, the Common Information Model, and provides a comprehensive management infrastructure with a consistent way of accessing it. It is a result of almost seven years of development, and it has been shipped as part of the operating systems since Windows 2000.
The WMI architecture (slide 10) is presented in this picture in a simplified way. As you can see, WMI provides management services to external applications via the DCOM interface. The information is gathered by providers, you can see them on the bottom of the picture, and is passed to the consumers or stored in the WMI repository. The use of schema is described in the way information is stored and accessed. As you can see, WMIC is one of the WMI consumers that provides a user interface to the infrastructure.
As it is implemented today, WMIC, first of all, is an administration tool (slide 11). It includes 80 aliases or friendly command-line names in each Windows .NET Server version. These aliases support about 150 methods, expose several thousand properties, and also provide reporting ability in TXT, HTML, XML, MOF (or managed object format), and CSV format (which is comma-separated value, suitable for import into Excel). WMIC allows access to other WMI instrumentations available in the box. So we are talking about more than 10,000 objects available for WMIC in a Windows .NET Server implementation.
WMIC provides two modes of operation. This slide (slide 12) presents both of them. On the left is an example of non-interactive mode. In this mode WMIC executes a command and escapes back to the command prompt. This is in batch file-scripting mode. On the right you can see an example of interactive mode. To enter this mode, you just type wmic and press ENTER from a command prompt. Then you just type any WMIC command from the prompt that WMIC provides to you. And you can see this example on your right. We will see more examples in a few minutes, in the demo part of this presentation. So I will now drill into more detail, which will allow you to understand how it operates.
Let us briefly review the WMIC architecture (slide 13) so we can better understand its principles and abilities. You can see from this picture that WMIC consists of three fully partitioned modules: aliases, at the top-left corner, the WMIC engine behind it, and transforms or XSL style sheets, in the bottom-right corner. After you type an alias name at a WMIC or command-line prompt say for example, process or OS, these are types of aliases or commands the WMIC engine parses the request and looks at the alias schema definition and what class instances and properties to access. The requested data then is retrieved from the WMI repository and processed into XML document structure. Next, XSLT or style sheet transforms are applied to produce the desired format. You can see in the top-right corner the two examples of the way you operate WMIC in both modes.
The following principles (slides 14) make WMIC a unique and powerful tool. It is a generic command tool, it is driven by instrumentation. It uses common grammar, so for all 80 aliases you have the same method of applying commands, and it provides transparent remoting. WMIC relies on progressive help discovery, which makes it easy to learn and to use. There is also total partitioning between aliases, the parser/engine, and transforms, which makes it very easy to interchange different parts. WMIC also allows you role-based management. For example, you can operate against various folders or namespaces and divide functionality this way. It can operate against single or multiple computers in one command, or you can operate WMIC by different functional teams or groups of users by assigning the specific aliases to specific folders or roles.
What can you do with WMIC? You can define aliases (slide 15), add output formats, and create and run scripts. You can browse the WMI schema and query its classes and instances. You can get information from a local computer, a remote computer, and from multiple computers in a single command.
The following scenarios are supported (slide 16). You can manage a local or remote computer. You can remotely manage multiple computers. You can connect to a remote computer and run WMIC from it. You can use batch scripting to automate management. Obviously, these are principle scenarios, and we'll drill into some examples during the demo.
Before going on, let's also look at how WMIC is centered in the enterprise environment (slide 17). In the network domain, it's enough to have one management station, with WMIC installed, to manage all computers with WMI or related instrumentation available on them.
Let us look at the examples (slide 18) of using WMIC and its aliases, using the demo environment in the following slide (slide 19). First of all, remember you have to be an admin on the computer to operate WMIC. To use WMIC interactively, type wmic from a command line, or a Windows-based UNIX shell like Interix, and press ENTER. At the WMIC prompt type /? or -? for help. This is the only thing you need to remember if you want to get started again. At this point, as you can see on this slide, the global switches and command aliases are listed for you. You can see what the global switches are, or environmental variables, if you wish, and all aliases available in the given namespace, which is called a role.
To see the default values of global switches, type context (slide 20). The value of NAMESPACE is root\cimv2, this is the namespace where the WMI infrastructure is related. So all your WMIC commands will be accessing this namespace, unless you specify explicitly that you want a different one. root\cli is the value of ROLE, and this is the namespace where WMIC aliases leave. NODE specifies the default computer that you're connected to. Then you have impersonation level (IMPLEVEL) and authentication level (AUTHLEVEL), which define your security settings. LOCALE specifies the language you use to display description and some localized data.
The rest of the switches are self-explanatory, except probably INTERACTIVE, which will be set to OFF by default. If you want to be prompted when you delete any classes and instances, you have to set it to ON. Setting the FAILFAST switch to ON will allow you to speed up accessing a list of multiple computers. WMIC will ping a connection before accessing it and it will skip it if the ping command is not returned. OUTPUT and APPEND will specify where you want your output to go. USER allows you to connect somebody else to use WMIC. AGGREGATE allows you to specify the way data is collected or appended to your STDOUT, and this is in case you have multiple nodes.
Aliases (slide 21) are predefined WMI queries. So when you type, for example, os, it would be equivalent to "get all properties from Win32_OperatingSystem" class instances and it will list them and their values using a table format. For every alias (and remember you can get them by using the /? at the opening prompt), properties are grouped using a list verb. For example, os list brief will display only the five or six most useful properties in a table format. os list full will display all properties in a property value pair. At the end of the presentation you can download a list of sample commands for every alias, so you can cut and paste them into your command window and try to see the difference in how they are grouped together.
To see what you can do with an alias, just type an alias name followed by /?, as you can see at the top of this screen shot (slide 22). If you get a message "Alias not found" like in this example, type /? from WMIC to check the spelling and see whether this alias is available. Remember, we have about 80 aliases available in the box. Now, as you can see in this example, every alias is always followed up by a verb indicating what action or task can be performed. Typing nicconfig /? will present you with six verbs available with these aliases.
If you type NICCONFIG ASSOC, you can find what objects are associated with these aliases. NICCONFIG CALL with a question mark, as you can see in the second part of the screen, will show you the methods available to be called and executed with this method, and the parameters available for this CALL command. NICCONFIG CREATE will be used to create instances for this specific class. You can also delete the instances (NICCONFIG DELETE). NICCONFIG GET can help you if you only want to display specific properties. NICCONFIG GET will list all the properties. If you want to see a specific one, you have to specify the property list and apply a different format. NICCONFIG LIST will list your predefined groups of properties.
In the next example (slide 23) we can see typing os /? will present us the options available for this particular alias. As you can see, there is another verb available, the last option, for OS SET. OS SET is only available if you have settable properties. It means if there are any properties, you can overwrite their value. In this case, if you're interested what these are, you just type os set /? and you can see on the bottom of the screen what the settable properties are for this one.
Formats: as I mentioned earlier, if you do not specify the format, a default is used. In most cases, these are either a table or a list. However, you can display the output using alternative formats, and those available could be displayed by typing /format /?, as you can see in this example.
The formats that we supply are serviced by keywords. You can see in this example that you can display the product list using CSV or comma-separated value format. You can use the HTML FORM for display lists. You can use the HTML version of MOF format, HTML TABLE, HTML XML, LIST format, RAWXML, TABLE format, and VALUE pairs, which are similar to LIST.
There are also two transforms available, which could be applied either before or after the format. It depends what do you want to do with your output. One available transform is NoComma. These are very useful for the comma-separated value format, if you want to ignore some commas for specific fields. Another format that is used for XML output is BasicXML. We will see some examples of these two later on.
The last slide for demo in this part is dealing with remoting (slide 25). Remoting is administered by using a NODE switch. You use the switch to specify the remote computer or a group of computers. As you can see in this example, the computers could be provided as a list of servers. Just type one after another. Or this could be inputted from a file name, which contains a list of all computers.
The next slide (slide 26) just shows a variety of commands and some options that I didn't cover. A sample of useful commands will be available at the end of this show. Just to point out some of these, if you look at Process Where Description="WinLogon.exe" Get VirtualSize /EVERY:5. So for the process, the name of it is WinLogon, you can get the property value of VirtualSize every 5 seconds. It's a very crude monitoring tool in this case, and sometimes this is very useful for you even if you use a monitoring tool that would not provide some specific properties you would like to monitor.
You can see, the NICCONFIG examples show you how you can enable or set specific values. The last one demonstrates how you can shut down a group of computers using a file name. So you just provide @ at the beginning of the path. The WMIC will realize that these are a list of servers coming from this file, and apply all the shutdown procedures one after another. Remember you can include FAILFAST command if you want to skip the computer that would be already out or shut down.
A couple of useful tips here (slide 27). There are several ways to use commands. You can go through these commands to cut and paste, and try it in your free time. For some aliases that are presented here, we suggest using the NamedParameters or WHERE clause so you could minimize the search time for a huge datasets like USERACCOUNT. For example, in some specific domains you can have hundreds of thousands of accounts, and going in and searching for this is very time consuming. So you need to specify your search, and using the WHERE clause is what you do in this case.
Also, NamedParameters are a brief version of the WHERE clause for which you don't need to write the WHERE "Name"= because it's already defined as a parameter, and you can see an example of this on the third line. You can see the second part of the command provides the path, which is a named parameter to access FSDIR aliases, the file system directory. So if you want to see the files and a specific directory, you can specify it here. You don't have to say that this is the name. As I mentioned, to discover what the named parameters are, we have introduced a method alias called ALIAS. This is the first line.
If you want to explore the alias itself, like the OS ALIAS, what you do is just type WMIC ALIAS OS or WMIC ALIAS OS LIST BRIEF. You will see the target of these aliases, such as the class it connects to, and what is the named parameter for this specific alias. Another useful tip at this stage is we suggest using the double quotes ("") rather than parentheses, because there could be some confusion in this case. But again, this is rare.
Probably another point to mention is if you paid attention when you specified the path, the backslash (\) WMI uses backslash and escape characters, so you'll probably have to, in most cases, use a double backslash (\\), because the first line will be used as an escape character. As I mentioned, there are plenty of examples that will be available for download, so you'll be able to see and feel how it works.
Let us move into advanced applications (slide 28), which many of you will derive very quickly and some of you already, I hope, are using. WMIC brings the end-to-end capacity to the management infrastructure because it not only exists if instrumentation could be accessed and utilized, but also after the application developer adds instrumentation, the command access immediately becomes available at no additional cost. It's easy to write a provider in the environment that the .NET Framework provides for all of you. With a little additional investment in defined aliases, the developer can simplify most of the common command operations. We will see later on some tips on how to perform customization.
Let's look into the architecture of WMIC again and look at supported instrumentation (slide 29). If you remember, aliases tell WMIC what to access and how to display. However, we can use PATH or CLASS commands to direct WMIC to this specific object without using aliases. The only condition is that we have to know the name of the object, as it will be the path of the search path.
For example, here on this slide you can see two commands, PATH and CLASS, using the class name to access the WMI schema, in this case. At the command or WMIC prompt, type this example: path win32_process get name, processid, handle. WMIC will go directly to the WMI, access the win32_process class, and get you the property you requested. The rest of the creation of XML document and applied style sheet is similar to the previous explanation.
Let us a look at a few examples that demonstrate these types of applications. Here is an example of using the PATH command (slide 31). You can see that typing path win32_process get name, priority, processid, and other properties will display them in the same way as if you said process get name priority processid, and so on. Again, because I didn't specify any formats on this example, the default one, a table is being used to display data to standard out, which is display screen.
The CLASS command is slightly different because it provides you the ability to get some schema information. When you use the CLASS command, the principle is the same. You have to type the class name you want to get, and this will be retrieved in the MOF format, which is displayed using HTML. So if you want to see it in a readable way, the best way is to redirect it to file in a HTML format and just display it as presented here in this example. This could be useful when you need to extend WMIC and modify its aliases or name properties. We will see this in a few seconds. But first of all, let us look at an example of using automation with WMIC.
Automation (slide 33) is available in several ways. You can use aliases to name them. You can modify MOF files. You can use the view provider to create new aliases or to create or shortcut procedures you want to display. The most common will be to use batch files, and to integrate scripting within these batch files, and write to commands that you use day by day. Probably one of the most widespread uses will be to operate and execute specific commands on a group of computers in your organization. This is an example showing how in one command you can protect all your computers in your domain from, for example, the recent UPnP-related virus. In this example, you can disable the specific discovery services by a command, and it would take a matter of minutes. It depends on how many computers you have.
How can you extend WMIC (slide 34)? First of all, you can customize existing aliases and their properties. You can define new aliases. You can add output formats or these .xsl files. You can create new transforms. You can create and run scripts, batch files. And you can browse the schema and query classes and instances of WMI or any new instrumentation. This is explained in more detail in this following slides.
Creating and editing aliases (slide 35): You can access three MOF files, which contain the definition of alias classes and their aliases, which have instances of CliAliases.mof. You can add and edit instances of this in CliEgAliases.mof. You will have to copy friendly names and descriptions to a .mfl file. This is CliEgAliases.mfl, and you will have to run the Mofcomp command to compile or to write the aliases into the root\cli namespace, or any other namespace, if you want to change the default.
In the next example (slide 36) what I did was I derived a small fraction of this schema. In this example it's an instance of MSFT_CliAlias, and there are 80 instances in the CliEgAliases.mof. If I forgot to mention it, these files are in the Windows directory, under System32\WBEM. These are text files. You can use Notepad to edit them. You need to remember to save them as unicode files. In this example, I just show if you don't like, for example, the friendly name or alias name "BIOS", you can make it even shorter. What you need to do is write any name you want within these double quotes, and you'll have to do it twice because of localization issues. So you have to do it in another instance with the localization property.
The same is true for Description. If you want to make description even more specific or more explicit, whatever you decide, you can do it here. Changing this and running Mofcomp on the saved class will create a different description and a different friendly name. So this is the simplest way of customizing it. Obviously, you can use the same structure to create your own aliases. What you have to remember is there should be a class specified by the target property where the alias should get the data from.
The next example (slide 37) shows you where you can define a new transform. Remember I mentioned there are two transforms available: one for ignoring commas and specific fields, and the other one is translating the raw XML into basic XML, and you can see the difference between these two is specified in FromValue and ToValue. So what you need to do is create a new transform just to write the name of that transform, and write what value you want to translate from and to.
The next example is showing (slide 38) you the way you can add or customize formats. XSL-mappings.xml is a kind of config file or mapping file that fits in the same directory as the MOF files, which I mentioned before, and it's in the Windows\System32\WBEM directory. As I mentioned before, you have to be an admin to access this directory. After you find the file there, you can read it in Notepad or an XML editor, and you can change the way we map keyboards to a specific style sheet transform. This is an .xsl transform that allows you, as you remember, to change the way you handle your output, and here we provide mappings to the keywords to existing ones. You can customize these as you want, and you can add your transforms if you wish.
The last example is reporting (slide 39), and this is one that probably is the culmination of the administrator tasks, but this is the more important one, and in many cases it's probably very time consuming. So we made the reporting easy for you, and there are several types of reports you can produce.
Namely, comma-separated values allow you to import files into Excel. And the htable allows you to produce an HTML report. Note you can filter the data using the WHERE clause, as in this example. Moreover, this particular style sheet, the htable, allows you to also sort the fields as you wish, and here are the examples of how it's done. This is available because WMIC produces XML DOM, which allows the data to be transformed and formatted.
I will finish here and then answer your questions. You can find additional information sources (slide 40) for WMI on the MSDN® Web site. You can send your e-mail to wmi@microsoft.com. If you want to know more about WMI, there are several books available, and some of them even have topics on WMIC. There are some articles on WMIC available in Windows magazines. Most importantly, there is a Help and Support Center in your computer. So go to Help and Support, type WMIC, and you will see very comprehensive help that augments the built-in help available with WMIC. Remember, /? will give you online help, and Help and Support Center will give you a lot of offline help on different topics. There also will be two lists of useful commands attached, available on this site. Please use them. I hope you enjoyed the show and you found this information of benefit to you. Thank you.
Otto Cate: Thank you very much for the presentation. Before we move into the Q&A portion of the Support WebCast today, I'd like to share a couple of program notes with everyone.
The Q&A portion of the Support WebCast is intended to encourage further discussion of the Support WebCast topic. One-on-one product support issues are really outside the scope of what we're able to address. However, if you do need technical assistance that possibly requires more complex one-on-one support, feel free to submit an incident on the Web, or contact Product Support Services and speak to a support professional by phone.
The first question that we have here, this appears to be a question concerning future versions: Do we have any public information concerning upcoming versions or patches, changes, anything of that nature, to WMI?
Arkady: Are we talking about WMI or WMIC?
Otto: I believe we're talking about WMIC. However, it is typed WMI.
Arkady: Let's try to answer both. For WMI, Windows .NET Server products will have a new version of it, an augmented version of WMI. Obviously, it will have an augmented version of WMIC. It will be slightly different and more enhanced than the version available in Windows XP. It will support, for example, handling different input parameters. But generally, these are very similar versions.
Otto: Next question: Is it going to be easier to manage the security in WMI? It can be quite tedious to give someone permission to view objects on different servers because they don't have administrative rights. Is that something that you've seen before, or is there an easier way to manage security?
Arkady: WMIC is intended for the administrator, and obviously if you need to perform an administration task, you have to be an admin on the remote machine that you want to shut down, or to delete a process. You have several switches available for you to implement different levels of security. For example, in Windows XP WMIC uses the default level of encryption. In the server version, we made the encryption packet privacy even more strict. But it's up to you to decide if you want to tighten or relax the level of security. As far as WMIC is concerned, there is some range of maneuvering there. With WMI we generally invested, as did all of Microsoft, several months in making security much tighter. You will be able to enjoy it, I hope.
Otto: I'm not exactly sure which slide they're referencing. The question is: Is it possible to see the transition of the alias somehow?
Arkady: I'm not sure what that means, the transition of an alias.
Otto: Perhaps we can get some follow up information from the user who asked that question. Let us know which slide you're referencing or possible clarify a little bit. We should be able to address it for you. Just type "follow up" in front of your comment, and I'll link it back to this one.
Next question: Does WMIC come as part of Windows XP Professional, or does it have to be installed on top? We also have several users who are curious if it can be installed on Windows 2000.
Arkady: WMIC is installed in both Windows XP and Windows .NET Server. It's compiled with aliases on your first start. So generally in Windows .NET Server, when you type WMIC the first time, you will see a message saying "Wait until WMIC compiles its aliases." The next time you use WMIC, it instantiates immediately. The only difference you'll notice is if you upgrade your computers, and you have some changes to your aliases, it will compile them again and you will have a slight delay. As for availability, Windows .NET Server will have WMIC available on all versions. WMIC ships on Windows XP Professional only. There is no WMIC on Windows XP Home Edition, because it's an admin tool, obviously.
As far as the Windows 2000 is concerned, no, you cannot port WMIC. You cannot copy and use WMIC on Windows 2000 because it requires an XML encoder. If you remember, WMIC builds on XML DOM, and this infrastructure is not, unfortunately, available on Windows 2000. However, it may be an important point to say it will not prevent you from accessing Windows 2000. If you remember the slide on managed enterprise, you have to have WMIC on one machine, and then you access any machine on which WMI or a schema you access is available.
Otto: Next question: For access to WMI, we have a COM interface, and now this new WMIC command-line interface. Are there any plans to implement a GUI interface, or are we pretty much sticking with the command line?
Arkady: You're asking about accessing WMI information using the GUI interface. I have good news for you. There are already several ways to do that. We have a tool called WMI Cim Studio, it's part of WMI tools, and it's available from http://www.microsoft.com/downloads/. If you just search for "WMI SDK" on the downloads page, you will find the link. I can't remember the link (http://www.microsoft.com/downloads/release.asp?ReleaseID=40804&area=search&ordinal=4), but just a search for either "WMI SDK" or "WMI tools." You will see several tools: WMI Cim Studio, WMI Object Browser, and there are two GUIs for supporting eventing. In addition, if you're a developer and you have Visual Studio® .NET, that ships with Server Explorer. And Server Explorer also has many of the WMI classes that can be accessed. We may have even more, but not in this release.
Otto: The next question is as follows: In a large, multidepartmental enterprise, how does WMI limit access to data from unauthorized users like other domains?
Arkady: WMI has name-based security, so your data is secured, in addition to general security. So you can set up the security permission; and in addition, you can secure WMI namespaces. This information is available from the documentation. As far as WMIC is concerned, only the administrator on a computer can access these infrastructures. So it is secured.
Otto: Next question: Does WMIC interactive mode provide keyword completion similar to hitting TAB at a MS-DOS® prompt to complete a file name, for instance?
Arkady: No. Unfortunately, WMIC does not support word completion yet. We hope very much to have it available in the next version.
Otto: Can you set restrictions to WMIC through Group Policy objects?
Arkady: I'm not sure I understand the question. The way you can limit the use of aliases, obviously we're talking about the admin rights; WMIC operates with admin rights. So if you want to limit a specific group of people who use these, you can only use it by using aliases. You can group the specific aliases and compile them on the part of a different namespace. For this group of people that you give them access to, those only will be available on that particular namespace. This is probably the only one that you can limit. I hope that answers the question.
Otto: Next question. It goes back to whether or not we can run WMIC on operating systems other than Windows XP and Windows .NET Server. Just a clarification, is it also not available for use on Windows NT 4.0 as well? Is that accurate?
Arkady: Let me clarify again. WMIC is only available on Windows XP Professional and all Windows .NET Server versions. This is where it's available, but you can access any other computer using WMIC, if it has WMI bits on it. It could not be ported to anything other than Windows XP or Windows .NET Server, because of the XML encoding infrastructure.
Otto: Thanks for the clarification. It looks like we still have a few questions in queue here. I just wanted to take some time to solicit some feedback from our audience. If you happen to have any suggestions for any future topics, or if you'd like to comment about today's session or even the WebCast program as a whole, we'd certainly love to hear from you. You can type the word "feedback" in front of your comments or suggestions and send them to supweb@microsoft.com.
Moving on to the next question: Is there any way to automate the output of WMIC results to a database other than simply outputting to a CSV or other format?
Arkady: If you are talking about specific database format, I guess the way to do it is to create an output format that will translate WMIC output to this specific format. You can use a text file, an ASCII format, or any proprietary format you want. Just input this into the file, which could be a simple batch file. However, the difficult part will be to write the style sheet that takes WMIC output and transforms to the specific format. I mean that's the difficult part of this task. If you're familiar with the XSL language, it probably would not be a difficult task to do at all. You have some examples, about 10 or so style sheets that we provide in the books that could be a good way to study.
Otto: Next question: Is there an editing command available, such as grep in the UNIX environment, to filter reports?
Arkady: No, not that I can think of, directly. Again, you can use XSL language to write a command that will filter it for you; or if you're looking for some specific properties for WMI, you can use it. You can vary filters to filter a specific property. But if you're talking about the output report, this is through style sheets.
Otto: Next question: What's the version number of the WMIC that you've shown us today?
Arkady: The examples I used are examples of the Windows .NET Server product, and this is being distributed to our better customers or our development partners. Examples should be available for all users this fall. As I mentioned, there is no big difference between this version and the Windows XP version, except some enhancements and some bug fixes.
Otto: Next question: What are the prerequisites to access a WMI provider like SNMP using WMIC? Are there any simple examples available for this type of scenario?
Arkady: If I remember correctly, the SNMP has a different namespace. So you're just using a namespace switch. You have to specify the location where the object of this provider is populated. As I mentioned, there will be a list of useful commands. You will see some examples of how you can get information from the SNMP provider, from the VDM or drivers. You can see examples of how you search and look for the namespaces or folders with different schemas available. As I mentioned, there are about 10. There are many other schemas available in the box. There is a lot of useful information for you.
Otto: There are a couple of users who are asking if we can elaborate a little on the localization issue. Some users are saying that it has caused them some difficulties in the past.
Arkady: The problems that we experienced there were some localization issues with Windows XP, mainly in the area of multiuser interfaces and the language packs. What happened was that WMIC automatically discovers the locale of your machine. So if you use an English machine, it will be using the English locale, and you remember there is a switch that tells you, when you type context, what the different locale is in your machine. However, some people install language packs or use the multiuser interface, and these unfortunately are not always localized for WMIC. What happens is that WMIC thinks that it has these because it reads it from system properties, and this is not available.
What you can do is always escape to the English locale. If you have any problems, just type /locale:ms_409. You'll see plenty of examples available. In Windows .NET Server, if there are localization languages not available for you, WMIC automatically escapes to the English locale, so you should not have any problem at all. For the Windows XP version, for some multiuser and localization packs, for any problems, just escape to the English locale and that should not be any problem at all.
Otto: I'm not sure if this is related to permissions: I'm using WMIC for the first time on Windows XP. It seemed to install, but when I type OS or any other alias, I'm getting some error messages that are hexadecimal error messages like 0X8004100E, something of that nature. Is that a permission-related issue?
Arkady: Probably not. It looks like you already can type wmic. It looks like you have a localization problem. What I suggest to do is type wmic /locale:ms_409. You want to set up your locale to English. You can see this example in one of the slides, when I used the context command. It shows you the locale. Type this and it will reset your locale. In interactive mode, this is what you will have to do. Please let us know if you have any problems.
Otto: Is it possible to use functions in transforms for string manipulation?
Arkady: Yes. It's just a matter of writing it in your transform.
Otto: A couple of users are curious of what the process is of actually starting WMIC. For instance: I have two WMIC services running. When I type in WMIC at the command prompt, it says "WMIC is not recognized as an internal or external command, operable program, or batch file." Is that an issue you've seen before?
Arkady: Not that I recall. I'm just trying to understand. So you're running two WMICs on the same machine? Maybe it's related to performance. It will be useful if you let us know what you use. Is it Windows XP Professional or the Windows XP Home? There is no WMIC on Windows XP Home, so I guess it's a Windows XP Home Professional machine. Can you give us more details about what's going on? No, we haven't seen this issue before.
Otto: If that user would like to follow up with a little bit of extra clarification, we'll match that back to that question.
Moving on here: If you create transforms or custom aliases on your own machine running WMIC, and you're doing remote administration, do you need to customize the MOF file on the client machine, or does it only have to be done at the administrative station?
Arkady: You don't need to do anything on the client machine. Your MOF file alias definitions and transforms should be on your server machine. So WMIC just goes there, gets information, brings it back, and it builds an XML DOM at your place. The alias will tell your machine where to go, and style sheets will format the data that's already arrived to your machine. Everything is done locally, and everything is in your control.
Otto: We have a follow up to one of the earlier questions. The original question was: Is it possible to see the translation of an alias? The follow up is: Basically, I was hoping you could see what aliases actually translate back to you. It sounds like you may have already addressed that. Is there something you could clarify possibly a little bit?
Arkady: I will try to explain what an alias is, and I do suggest that the best thing is to look at one of the alias instances. The alias generally is an instance of an alias class. It's a proprietary way of specifying, using the same model. The alias is really a reflection of WMI CLIs. What it does is create a MOF definition that says what the name should be. The name is related to what class to access, and it says what other properties should be accessed and what name to display. Also, it gives you a verb that specifies the method calls available for this specific class. I would say if you're familiar with the reflection paradigm, reflection is one of the best descriptions of an alias. It's a reflection of the WMI schema. I hope I answered the question. Again, I'd be happy to clarify in an e-mail, or please follow up here.
Otto: A little earlier you mentioned a URL for WMIC publications. We're curious if you could repeat that URL.
Arkady: The URL, which is on the last slide (http://msdn.microsoft.com/), it's not for WMIC publications, it's for WMI publications. There are no specific WMIC publications. However, there was an article in Windows 2000 & .NET Magazine. If I remember correctly, it's either the March or April 2002 issue of the magazine (http://www.winnetmag.com/Articles/Index.cfm?ArticleID=23854; note that this link is external to the Microsoft domain, and Microsoft is not responsible for its content). What I did mention for WMIC is Help and Support Center. The Help and Support Center is a new way of providing dynamic help to user on both Windows XP and Windows .NET. To start or to run Help and Support Center, click the Start button, and one of the options will be Help and Support.
Otto: Next question: Is WMIC only for OS information, or are you able to retrieve information from Exchange and Application Center to get information from Perf Counter?
Arkady: Absolutely. You can definitely retrieve information from Exchange, Application Center, and from others. There are several ways of doing this. There are some providers that provide it in WMI. However, many applications have namespaces that they implemented, so you can go to these namespaces and look for this information as well. Exchange has its own namespace at the root. You can look there to see, and you can use PATH and CLASS commands to get this information. The most useful is WMI. Remember WMI is a management infrastructure, so it is bringing you information about OS, Perf Counter, and applications running on your computer. We're talking about 600 classes, so 3,000 or 4,000 instances are available in the box.
Otto: You may have already addressed this, but I wanted to throw it out just in case: After the first launch of WMIC, after you have run it, will it compile new, self-created MOF files on its own, or is that a manual process?
Arkady: If you take the provided files like CliEgAliases.mof, if you change this one, it will be MOF compiled automatically. WMIC always checks, and if there are some changes it will recompile it. If you created a new one, and this is another way to customize, you will have to run your own compilation command as follows.
At the command prompt, just write Mofcomp, a space, the name of your MOF file, and it will be compiled. The instance is written into the WMI repository. If you need more information about the way that the compiler runs, just type Mofcomp /? and you will see the options available for you.
Otto: On the Support WebCast page for today we have a link to examples of WMIC commands. A couple of users are curious: One of the commands was used as an alias for RDTOGGLE, Remote Desktop, actually under .NET Server, but we're not seeing it necessarily available for Windows XP. Is RDTOGGLE supposed to be available for Windows XP, or will the versions at some point come into one another?
Arkady: RDTOGGLE is a new alias. I should have probably been more specific. There are a few new aliases in Windows .NET Server. RDTOGGLE is one of them. However, these aliases should be available in Windows XP under the Win32_TerminalService classes. You look at the example, when you say RDTOGGLE (Remote Desktop Toggle), this one is providing a PATH command to Win32_TerminalServiceSetting class. Try to remember that these are implemented on Windows XP, so you can use the PATH command, and you do it the same way as with RDTOGGLE in Windows .NET Server. I hope that answers your question.
Otto: Does WMIC support all of the same levels of impersonation as WMI does through current scripting techniques?
Arkady: Yes, it does. WMIC is another way of writing scripts, and it uses the same interface.
Otto: I'm not sure exactly which question they're referencing. The question is this: What is the syntax to control the format of the output again? I'm assuming we're talking output to CSV.
Arkady: Obviously, when you type a command and do not specify format, you will get the default format. As I mentioned, the default format we provided in most of the cases is either a table or list. If you want to change it, you will have to specifically specify the format using the FORMAT switch. So /format column, a keyword like CSV, hform, htable, or a specific .xsl file, will do it. To summarize, if you want to use a specific format, you have to use a FORMAT switch to do it. There are plenty of examples available. If you want to see more, just type OS get <some property> /format /?. Remember /? will give you the options available and when you do format/?, it will show you help on this topic. If you want to get even more, go to the Help and Support Center, search on WMIC, and look at this section dealing with formats, it will give you all the formats available as well.
Otto: Can you also get information from Active Directory®?
Arkady: Yes, absolutely.
Otto: This is a follow up on the RDTOGGLE. I'm not seeing Terminal Services under Windows XP. Can you possibly clarify that a little bit more?
Arkady: I'm not sure what you're saying. If you have in front you the list of commands we attached, maybe you don't have it on the list that I attached. But there is class called win32_TerminalServiceSetting. I'll give you a command to try, and you can try to do it, or use one of the browsers to find the class name. What you can do is WMIC /NODE:computername PATH win32_TerminalServiceSetting WHERE servername="computer1" call SetAllowTSConnections. The point is, if Terminal Services is available on your computer, there should be a class there, and this class is in root\cimv2 directory together with all other WMI classes.
Maybe I'm wrong and the Terminal Services are not available, which I doubt. As far as I know, Terminal Services are available. Command-line aliases are something that's available for Windows .NET Server. But the services are there, and so it should be classed there. What I suggest is because these classes in the MOF files are text-based, you can search on the string with one of the command lines or any utilities. So you can try to get this from a MOF file, which is in the WBEM directory, and see exactly the name of the class. You can see that the trivial issue of the name of the class can be a common obstacle for administrators who can operate with hundreds, maybe thousands of different classes available today.
This is where the notion of aliases is very appealing, because it solves the discovery of them and is very intuitive. So you say RDTOGGLE, OS, PROCESS these are things that you remember and you're never mistaken. Once you need to operate with a PATH win32_terminalservice setting to set or config the service, you are lost. This way we think you'll probably be able to use and customize aliases as we envisioned.
Otto: Can I redirect output to a file in interactive mode? I know we may have touched on this. This is just a clarification.
Arkady: Yes. The way to do it is using switches. If you look at the CONTEXT command there are several switches, and one of them is called OUTPUT. If you put OUTPUT in front of your command, and you remember there are contexts that contain global switches, global switches go in front of your alias, and there are local switches going out to specific verb or format. If you put /output <filename>, it will be redirected to a file name you specify. If you use the APPEND switch and aggregate, you can even decide if you access several servers, these files are appended to exist in files and groups according to the server or node names. Please let us know if you have more questions.
Otto: In this the slide we covered some articles on MSDN, and searching for WMIC in the Help and Support Center. Of course, there are several books available. The user is just asking if there are more examples available elsewhere, short of the ones that we've posted up on the Support WebCast site today. Or can those be found within the Help and Support Center?
Arkady: Just to clarify, the books are about WMI. Some of them, probably one, do mention WMIC briefly. WMIC is a new utility, so there is not much publicly available on it. Remember, Windows .NET Server still is not publicly available.
As far as the examples are concerned, I'm not sure what you're able to access, but there are two lists that are available. One has examples of commands for every alias, and the one with different management scenarios. This is pretty much it. I'm not aware of any publicly available list. It could be a good idea to initiate a WMIC newsgroup on one of our online communities, so that people can exchange aliases, can exchange commands, and useful tips, but I'm not aware of these yet. The commands we provide are pretty much it. It's always possible to provide much more, and we shall try. The Download Center (http://www.microsoft.com/downloads/) will be available on this page, and I will check whether we can post a more exhaustive list of commands later. I will try to provide you more, as much as we can.
Otto: With that, it appears that we've answered all of the questions that were submitted today. Actually, there is one more that just snuck in here. I'm going to ask this one: Can the items in the context section be saved as default after changing them?
Arkady: No. Unfortunately, not yet. In the interactive mode you will have to do it every time you open this particular window. In non-interactive mode, what you do is you just write a batch file and you specify the settings in front of your command.
Otto: Thank you. With that, we've answered all of the questions. We're going to wrap up the session here today. I want to thank everyone for joining us, and hope that this information was useful to you. I also want to thank Arkady for coming out and giving us a great presentation, and answering a ton of questions definitely good information.
Arkady: Thank you for logging in, and please let us know if you still have any questions. We'll be happy to answer them. Thank you.
Otto: I hope that everyone has the opportunity to tune in again in the near future. Thanks, and have a great day.