wc 072402

41
WMIC: A New Approach WMIC: A New Approach to Managing Windows to Managing Windows Infrastructure from a Infrastructure from a Command Line Command Line Arkady Retik Arkady Retik Program Manager Program Manager Windows Server Division Windows Server Division Microsoft Corporation Microsoft Corporation

Upload: avatarzzzz

Post on 03-Oct-2015

219 views

Category:

Documents


6 download

DESCRIPTION

A New Approach to Managing Windows Infrastructure from a Command Line

TRANSCRIPT

  • WMIC: A New Approach to Managing Windows Infrastructure from a Command Line

    Arkady RetikProgram ManagerWindows Server DivisionMicrosoft Corporation

  • ObjectivesReview Windows Management Instrumentation Command-Line (WMIC) utility and its architectureDemonstrate the modes of operationIntroduce the advanced use of WMIC

  • AgendaBackgroundArchitectureExamples of useReviewAdvancedExtending WMICCustomizing WMIC

  • WMIC: WMI Command-Line ToolAccess 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]

  • Why WMIC? Customers IT administrators Non-programmers User interface to WMIValue Use of intuitive aliases Simple ad hoc access to instrumentation ExtensibleCons Limited eventing support

  • Why WMIC? (2)In fact, I think that WMIC is one of the best tool that came out in the recent years, just because it givesyou the power of WMI without being a developer. Noteverybody in my team is familiar with WSH, VBScriptand WMI, so writing scripts that leverage WMI tomanage Windows servers could not be done byanybody. With WMIC, they can, without knowing toomuch about WMI itself - just great...

    an IT Admin

  • Management Tools Strategy Manageability MethodsOut of bandRemote ConsoleRemote GUIAutomated/preset EMS (Remote Serial) Cmd Line / Simple scripting WMIC

    Para-programming/ Complex scripting Terminal Server MMC Web Admin WMI Tools Policy RIS Automated setupAdmin focused Pre-built .exe Pre-built .vbs Batch files Redirection / Piping WMIC adds extensibility Programmer or sophisticated admin Build your own tools or complex scripts Win32 APIs COM Objects WMI & ADSI interfaces for scripting Command Line Tools Program

  • 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 *

  • Windows Management Instrumentation (WMI)Goals

    Make Windows the most manageable OSProvide a comprehensive management infrastructure, removing the need for management agentsEnable system and application observation and controlConsistent queries Consistent methods Consistent events Consistent protocol Consistent schemaAvailability

    Windows 95 Windows 98 Windows NT 4.0 Embedded NT --------------------Windows 2000 Windows Me Windows XP Windows .NET ServerPartners (redistributed w/ OEMs / ISVs / IHVs)

  • WMI Architecture Point-to-PointWMI Providers (loaded on demand)WMI CIM Management Schema WMI ServicesQueryServicePub/SubServiceSNMPActiveDirectoryWMI extfor WDMWindows NT Event LogPerfCountersRegistryWMI RepositoryViewServiceSchema RT / Provider SubsystemEvent FilteringODBCAdapterODBCClientWBEM ConsumerScriptADSI Ext. AdapterADSIClientDCOMSWBEMDCOM

  • Windows XP Professional and .NET Server implementation

    WMIC is an admin tool WMIC includes 80 aliases (FriendlyCommandNames):Supporting about 150 methodsExposing thousands of propertiesProviding reporting ability in TXT, HTML, XML, MOF, CSV, or any proprietary formatIt allows access to any CIM-like schema object (greater than 10 KB in the box)

  • WMIC: Two Modes of Operationc:\>wmic process list brief wmic:root\cli>/?

  • WMIC Architecture

    WMI

    ProviderProviderProviderProviderProviderXSLTXSLTXSLTXSLTXSLTXSLTConsoleHTMLCSVMOFCustomer definedXMLDOMWMICEngineAlias(FriendlyName)Definitions

    WMI

    Two ways of using: - C:\> wmic process (scripting/batch mode) - wmic:root\cli> process (interactive mode) Examples of interactive mode: > OS get name, locale, bootdevice > OS where name='sun' call shutdown > /node:@MyOrg os get /all /format:htable

    AliasSchema

  • PrinciplesGeneric command-line tool:Driven by instrumentationUses common grammarProvides transparent remotingProgressive help discovery Total partitioning between:AliasesParser/engineTransformsRole based management:Operating against various folders (namespaces)Operating against single and multiple computersOperated by functional teams

  • WMIC AbilitiesDefine aliases, add output formats, and create and run scriptsBrowse the WMI schema, and query its classes and instancesGet information from a local computer, a remote computer, and from multiple computers in a single command

  • ScenariosManage a local or remote computerRemotely manage multiple computers Telnet to a remote computer and run tools Use scripting to automate management

  • WMIC in Enterprise

    ManagementStation(Windows XP Professional or. NET Server)

  • Examples of Using WMIC and Its Aliases

  • Getting Started Default Settings

    *

  • Getting Started Context

    *

  • Getting Started Aliases

    *

  • Using Progressive Discovery Help

    *

  • Using Verbs

    *

  • Using Formats

    *

  • Remoting

    *

  • Examples of CommandsQFE

    PRODUCT or PRODUCT list brief or PRODUCT list full

    cpu get MaxClockSpeedList

    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*

  • Some Useful TipsNamedParameters or WHERE clause for large datasets:

    WMIC ALIAS OS or WMIC ALIAS OS LIST BRIEF

    WMIC USERACCOUNT WHERE "Name='PutUserNameHere' and Domain='PutDomainNameHere'"

    WMIC FCDIR 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)

    *

  • 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)

  • Supporting Instrumentation

    > PATH [verb] [properties] [format] query Instances of a Class Example:> path win32_process get name, processid, handle> /node:@list.txt path HardwareConfig call DriverUpdate

    > CLASS [verb] [properties] [format] query Class propertiesExample: > wmic class win32_share >ShareSchema.htmlProviderProviderProviderXSLTXSLTXSLTXSLTXSLTXSLTConsoleHTMLCSVMOFCustomer definedXMLDOMWMICEngineDirect Access:PATH/CLASScommands

    Any WMI Schema

  • Examples of Using WMIC to Directly Access Instrumented Data

  • Using the PATH Command

    *

  • Using the CLASS Command

    *

  • Automating WMICNew customization and developmentAliases, MOFs, view provider, Through applicationBatch files, scripting, Example: WMIC /NODE:@"c:\MyServerList.txt" SERVICE WHERE caption="SSDP Discovery Service" CALL ChangeStartMode "Disabled"

    MyServerList.txt

    Server1 Server6 .Server2 Server7 .Server3 Server8 .Server4 Server9 .Server5 . Server1024

    *

  • How You Can Extend WMICCustomize existing aliases and propertiesDefine new aliasesAdd output formats (*.xsl)Create new transforms Create and run scriptsBrowse a schema and query its classes and instances

  • 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.mflMofcomp the files

  • Examples of CustomizationDefining 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."};};

  • 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 = "wmic ntevent where "eventtype

  • Additional Information Sourcesfor WMIWMI articles on the MSDN Web site at http://msdn.microsoft.com/Send e-mail to [email protected] Several books about WMI are availableHelp and Support Center

  • Thank you for joining todays Microsoft SupportWebCast.

    For information about all upcoming Support WebCasts, and access to the archived content (streaming mediafiles, 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 [email protected].