Creating and editing formats in WMIC

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Creating and editing formats in WMIC

Windows Management Instrumentation Command-line (WMIC) uses two types of formats to display properties: LIST format and OUTPUT format.

LIST formats allow displaying and recording of the properties of an alias in a specific way, such as:

List Format Properties

Process list brief

displays a short list of properties.

Process list full

displays a full list of properties (this is similar to process get /all).

Process list memory

lists properties related to a process memory.

To see what LIST formats are available for an alias, type:

<alias name> list /?.

For example:

os list /? 

Each LIST format has a default output format name specified as part of alias definition. For example, FULL is usually associated with TABLE, while BRIEF, with LIST (value list).

As an optional step, add the LIST formats group to the alias class. This makes the formats discoverable and easier to use. You can also specify the default stylesheet to be used for the format output.

OUTPUT formats are provided by WMIC using the /FORMAT switch to display and record output in a desired way. WMIC uses Extensible Style sheet Language (XSL) to transform and format the Extensible Markup Language (XML) output. The provided formats are stored in the WBEM directory as XSL files. Formats are used with GET, or LIST. Specific formats can be specified using GET /FORMAT:, LIST /FORMAT:, GET /ALL, or GET /VALUE.

Use an XSL editor. You might want to first capture some XML data to use for experimenting while using the XSL editor.

Custom formats may be created to display WMIC queries. If you create custom formats, you should also define them in the Formats property of the MSFT_CliAlias class. Each format must have a name that is unique within the alias.

Other Output formats are included in WMIC. These formats can be set as defaults or as specified using keywords:

Keywords Output Formats

mof.xsl

Converts XML data to Managed Object Format (MOF) format. If aliases or other WMI objects are defined in XML format, this XSL can be used to convert them to MOFs so that they can be MOFCOMPed. - /FORMAT:MOF format.

texttable.xsl

/ALL or /FORMAT:TABLE.

texttable.xsl

/VALUE format—one line per value.

For more information on mapping, see XSL-MAPPINGS.XML in %windir%\system32\wbem.

Additional XSL files that are included in WMI and can be useful when you use WMIC are:

XSL Files  

xml.xsl

Similar to rawxml.xsl, except that the output is in HTML format.

hform.xsl

Html output—the data is displayed in a vertical table (one row per property or instance name). The table can be very long.

htable.xsl

Html output—the data is displayed in a horizontal HTML table (one row per instance). The table can be very wide. you can specify the column that the data is typically sorted by. Enclose this file name in quotation marks. The column and its datatype are specified by using the following syntax: /FORMAT:"htable.xsl":"datatype=<datatype>":"sortby=<property>". For example, PROCESS GET /FORMAT:"htable.xsl":"datatype=number":"sortby=ProcessId".

rawxml.xsl

To output XML data in XML format. All WMIC data is extracted in XML format, so this format gives you data the way that WMIC sees it. This can be useful for creating your own XSL files. Outputting data in XML format is also useful if you want to provide the data to systems that accept XML data.

csv.xsl

Comma-delimited—the data is displayed with commas between each value. This format is suitable for importing the data into Microsoft Excel or a similar program.

Caution

  • When editing default views, be sure to save your changes to a format outside WMI. If you update WMI or the operating system, the new version of WMIC might return the aliases or output formats to the defaults, overwriting your changes.

For step-by-step procedures on how to create and edit formats, see Create a format in WMIC and Edit a format in WMIC.

For more information, see Windows Management Instrumentation Command-line.