410 likes | 796 Views
2. Objectives. Review Windows Management Instrumentation Command-Line (WMIC) utility and its architectureDemonstrate the modes of operationIntroduce the advanced use of WMIC. 3. BackgroundArchitectureExamples of useReviewAdvancedExtending WMICCustomizing WMIC. Agenda. 4. WMIC: WMI Command-Line Tool.
E N D
1. WMIC: A New Approach to Managing Windows Infrastructure from a Command Line
2. 2
3. 3 Background
Architecture
Examples of use
Review
Advanced
Extending WMIC
Customizing WMIC Agenda
4. 4 WMIC: WMI Command-Line Tool Access various sources of management data through WMI without programming
A new tool: Only available on MicrosoftŽ WindowsŽ XP Professional and Windows .NET Server Family products
Note: wmic pronounced [wee-mek]
5. 5 Why WMIC?
6. 6 Why WMIC? (2)
7. 7 Management Tools Strategy
8. Command-Line Tools Program Simplicity
Top tasks covered with new command-line tools
Admin focused, easy, and pre-built
Automation enhancements
Power and extensibility
WMIC new WMI command-line interface
Exposes all WMI management data
Customize queries for any scenario
9. 9 Goals
Make Windows the most manageable OS
Provide a comprehensive management infrastructure, removing the need for management agents
Enable system and application observation and control
Consistent queries
Consistent methods
Consistent events
Consistent protocol
Consistent schema Availability
Windows 95Windows 98Windows NTŽ 4.0Embedded NT--------------------
Windows 2000Windows MeWindows XP
Windows .NET Server
Partners (redistributed w/ OEMs / ISVs / IHVs)
Windows Management Instrumentation (WMI)
10. 10 WMI Architecture Point-to-Point
11. 11 Windows XP Professional and .NET Server implementation
WMIC is an admin tool
WMIC includes 80 aliases (FriendlyCommandNames):
Supporting about 150 methods
Exposing thousands of properties
Providing reporting ability in TXT, HTML, XML, MOF, CSV, or any proprietary format
It allows access to any WMI-like schema object (more than 10,000 objects in the box)
12. 12 WMIC: Two Modes of Operationc:\>wmic process list brief wmic:root\cli>/?
13. 13 WMIC Architecture
14. 14 Principles Generic command-line tool:
Driven by instrumentation
Uses common grammar
Provides transparent remoting
Progressive help discovery
Total partitioning between:
Aliases
Parser/engine
Transforms
Role based management:
Operating against various folders (namespaces)
Operating against single and multiple computers
Operated by functional teams
15. 15 WMIC Abilities Define aliases, add output formats, and create and run scripts
Browse the WMI schema, and query its classes and instances
Get information from a local computer, a remote computer, and from multiple computers in a single command
16. 16 Scenarios
17. 17 WMIC in Enterprise
18. 18
19. Getting Started Default Settings
20. Getting Started Context
21. Getting Started Aliases
22. Using Progressive Discovery Help
23. Using Verbs
24. Using Formats
25. Remoting
26. Examples of Commands QFE
PRODUCT or PRODUCT list brief or PRODUCT list full
cpu get MaxClockSpeed
Process Where Description="WinLogon.exe" Get VirtualSize /EVERY:5
SERVICE WHERE CAPTION='TELNET' CALL STARTSERVICE
NICCONFIG WHERE index=1 CALL EnableStatic ("10.0.0.2"),("255.0.0.0")
NICCONFIG WHERE index=1 CALL SetGateways ("10.0.0.8","10.0.0.9"),(1,2)
/NODE:@"c:\MyServerList.txt" OS WHERE (Primary="TRUE" and Organization!="Organization1") CALL Win32ShutDown 6
27. Some Useful Tips NamedParameters or WHERE clause for large datasets:
WMIC ALIAS OS or WMIC ALIAS OS LIST BRIEF
WMIC USERACCOUNT WHERE "Name='PutUserNameHere' and Domain='PutDomainNameHere'"
WMIC FSDIR WHERE Name='c:\\WINDOWS or WMIC FSDIR C:\\windows
WMIC DATAFILE WHERE "PATH='\\windows\\' and Extension='exe' and FileSize>'108032'" GET LastAccessed, LastModified, Name, FileSize
WMIC NTEVENT WHERE "LogFile='system' and Type>'0'" GET Message, TimeGenerated
Use "" to separate "WHERE" expression instead of () :
WMIC NTEVENT WHERE "LogFile='system' and Type>'4'"
Opposite to: WMIC NTEVENT WHERE (LogFile='system' and TYPE>4)
Shell will misinterpret >4) and will try to redirect output to file named 4)
28. 28 Advanced Applications WMIC brings the end-to-end capability to the management infrastructure:
The application developer adds instrumentation*, and command access immediately becomes available at no additional cost.
With little additional investment in defining the alias, the developer can simplify most of the common command (cmd) operations.
* This is simplified in Microsoft .NET Framework (versus .NET)
29. 29 Supporting Instrumentation
30. 30
31. Using the PATH Command
32. Using the CLASS Command
33. Automating WMIC New customization and development Aliases, MOFs, view provider,
Through application
Batch files, scripting,
Example:
WMIC /NODE:@"c:\MyServerList.txt" SERVICE WHERE caption=
"SSDP Discovery Service" CALL ChangeStartMode "Disabled"
MyServerList.txt
34. 34 How You Can Extend WMIC Customize existing aliases and properties
Define new aliases
Add output formats (*.xsl)
Create new transforms
Create and run scripts
Browse a schema and query its classes and instances
35. 35 Creating and Editing Aliases Access files:
CliAliases.mof Alias class and namespace definitions
CliEgAliases.mof Aliases instances
CliEgAliases.mfl Aliases localization
Add and edit instances in CliEgAliases.mof
Copy aliases friendly names and descriptions to CliEgAliases.mfl
Mofcomp the files
36. 36 Examples of Customization Defining and editing aliases (friendly names) or property names
instance of MSFT_CliAlias
{
Connection =
.........................................
Description = "Basic input/output services (BIOS) management.";
Formats =
........................................................................
FriendlyName = "BIOS";
..................................................
Target = "Select * from Win32_BIOS";
};
instance of MSFT_LocalizablePropertyValue
{
RelPath = "MSFT_CliAlias.FriendlyName=\"BIOS\"";
PropertyName = "Description";
Text = {"Basic input/output services (BIOS) management."};
};
37. 37 Examples of Customization (2) Defining a new transform:
instance of MSFT_CliTranslateTable
{
Name = "BasicXml";
Tbl =
{
Instance of MSFT_CliTranslateTableEntry
{
FromValue = ">";
ToValue = ">";
},
Instance of MSFT_CliTranslateTableEntry
{
FromValue = "<";
ToValue = "<";
}
};
};
38. 38 Examples of Customization (3) Defining and adding new formats:
Xsl-mappings.xml
<XSLMAPPINGS>
<XSLFORMAT KEYWORD="TABLE">texttable.xsl</XSLFORMAT>
<XSLFORMAT KEYWORD="VALUE">textvalueList.xsl</XSLFORMAT>
<XSLFORMAT KEYWORD="LIST">textvalueList.xsl</XSLFORMAT>
<XSLFORMAT KEYWORD="RAWXML">rawxml.xsl</XSLFORMAT>
<XSLFORMAT KEYWORD="HTABLE">htable.xsl</XSLFORMAT>
<XSLFORMAT KEYWORD="HFORM">hform.xsl</XSLFORMAT>
<XSLFORMAT KEYWORD="HXML">xml.xsl</XSLFORMAT>
<XSLFORMAT KEYWORD="HMOF">mof.xsl</XSLFORMAT>
<XSLFORMAT KEYWORD="CSV">csv.xsl</XSLFORMAT>
</XSLMAPPINGS>
39. Examples of Customization (4) Reporting:
C:\>wmic ntevent where "eventtype<3 and logfile='Application'" get logfile, SourceName, eventtype, TimeGenerated /format:htable:"datatype=number":"sortby=EventType" > c:\applicationLog.htm
C:\>applicationLog.htm
40. 40 Additional Information Sourcesfor WMI WMI articles on the MSDN Web site at http://msdn.microsoft.com/
Send e-mail to wmi@microsoft.com
Several books about WMI are available
Help and Support Center
41. Thank you for joining todays Microsoft Support
WebCast.
For information about all upcoming Support WebCasts,
and access to the archived content (streaming media
files, PowerPointŽ slides, and transcripts), please visit:
http://support.microsoft.com/webcasts/
Your feedback is sincerely appreciated. Please send any
comments or suggestions about the Support
WebCasts to supweb@microsoft.com.