Microsoft® Windows® Scripting with WMI: Self-Paced Learning Guide

Book description

Get the inside track on how to write system administration scripts with Windows Management Instrumentation (WMI), straight from Microsoft scripting experts. This practical learning guide teaches how to use WMI scripting techniques to gain control over your Microsoft Windowsâ??based, IIS-based, and Microsoft Exchange Serverâ??based environmentsâ??all at your own pace.

Build practical skills on everything from understanding the ins and outs of WMI and producing your first WMI Script to writing advanced WMI scripts that automate the management of systems, network services, files, printers, the registry, network services, and more. The companion CD features the complete eBook, 140 sample scripts, and timesaving scripting tools, plus more than 500 bonus scripts!

Visit the catalog page for Microsoft® Windows® Scripting with WMI: Self-Paced Learning GuideVisit the errata page for Microsoft® Windows® Scripting with WMI: Self-Paced Learning Guide

Table of contents

  1. Cover
    1. Copyright Page
  2. Contents at a Glance
  3. Table of Contents (1/3)
  4. Table of Contents (2/3)
  5. Table of Contents (3/3)
  6. Acknowledgments
  7. About This Book
    1. Background
    2. Editorial Objectives and Approach
    3. Is This Book for Me?
    4. Organization of the Book
      1. Part I: Getting Started with WMI
      2. Part II: WMI Queries and Events
      3. Part III: Connect Server and Additional Privileges
      4. Part IV: Classes
      5. Part V: Security and Troubleshooting
      6. Part VI: Appendixes
    5. About the Companion CD
    6. Computer System Requirements
    7. Technical Support
  8. Part I: Getting Started with WMI
    1. Chapter 1: Introducing WMI
      1. Before You Begin
      2. Defining WMI
      3. Querying and Starting a Service
        1. Defining the Query
        2. Evaluating the State of the Service
      4. Capturing the Return Code
      5. Using WMI as a Tool
      6. Implementing Microsoft WBEM
      7. Describing Objects Using the CIM (1/2)
      8. Describing Objects Using the CIM (2/2)
        1. Working with Namespaces
        2. Working with Providers
        3. Understanding Classes
      9. Implementing Programming Interfaces
      10. Using the WMI Architecture
      11. Using Managed Objects and Providers
      12. WMI Infrastructure
        1. WMI Applications
        2. WBEM Repository
        3. Location
        4. Retrieving from the Repository
        5. Handing Off to a Provider
      13. Summary
      14. Quiz Yourself
      15. On Your Own
        1. Lab 1 Installing and Configuring the Core Platform SDK
        2. Lab 2 Online Install (Optional)
        3. Lab 3 Navigating the SDK
    2. Chapter 2: Configuring WMI
      1. Before You Begin
      2. Understanding the WMI Control Snap-in
      3. Configuring Logging
      4. Backing Up the WMI Repository
      5. Restoring the WMI Repository
      6. Changing the Target of Operations
      7. Understanding Registry Settings
        1. Enabled
        2. LogSecurityFailures
        3. LogSecuritySuccesses
        4. Remote
      8. Using the CIM Object Manager
      9. Implementing Providers
        1. Configuring WMI Service Settings
      10. Automatically Recovering Providers
        1. Initial Installation
        2. Manually Editing the Autorecover MOF Key
        3. Adding the #pragma autorecover tag to the MOF File
        4. Using Mofcomp.exe
      11. Exploring WMI Settings with WMI
      12. Summary
      13. Quiz Yourself
      14. On Your Own (1/2)
      15. On Your Own (2/2)
        1. Lab 4 Backing Up the WMI Repository
        2. Lab 5 Restoring the WMI Repository
        3. Lab 6 Exploring WMI Settings via Script
  9. Part II: WMI Queries and Events
    1. Chapter 3: Using Basic WMI Queries
      1. Before You Begin
      2. Understanding WQL
      3. Using the Moniker
        1. The Prefix
        2. The Security
        3. The Path
      4. Using the Defaults
      5. Understanding Data Queries
      6. Using the Select Statement
        1. Select Everything from Everything
        2. Select Some Things from Everything
      7. Where Is the Where Clause? (1/2)
      8. Where Is the Where Clause? (2/2)
        1. Select Everything from Some Things
        2. Comparison Operators
        3. Select Some Things from Some Things
        4. IS Operator
        5. Compound Where Clause
        6. Is Not Operator
      9. Understanding Event Queries
      10. Understanding Schema Queries
        1. SWbemObject
        2. SWbemObjectPath
      11. Summary
      12. Quiz Yourself
      13. On Your Own
        1. Lab 7 Exploring Win32_NTDomain
        2. Lab 8 Using Schema Queries
    2. Chapter 4: Using Advanced WMI Queries
      1. Before You Begin
      2. Using __Class
      3. Using ISA
      4. Scripting API Objects
        1. SWbemServices
      5. Using the associators of Command
      6. Using the references of Command
        1. Modifying the Where clause
      7. Using the ExecQuery Method
        1. Returning an SWbemObjectSet Collection
        2. Iflags
        3. Error Codes
      8. Using the Get Method (1/2)
      9. Using the Get Method (2/2)
        1. SWbemLastError
        2. SWbemObject
        3. SWbemObjectPath
        4. SWbemObjectSet
        5. SWbemProperty
        6. SWbemPropertySet
        7. SWbemSink
      10. Introducing New Objects in Windows XP and Windows Server 2003
        1. SWbemDateTime
        2. SWbemObjectEx
        3. SWbemRefresher
        4. SWbemRefreshableItem
        5. SWbemServicesEx
      11. Summary
      12. Quiz Yourself
      13. On Your Own
        1. Lab 9 Working with the AutoDiscovery Process
        2. Lab 10 Using the Get Method for Inventory Types of Data
    3. Chapter 5: Using WMI Events
      1. Before You Begin
      2. Using SWbemEventSource
        1. NextEvent
        2. Security_
      3. Working with SWbemServices
        1. ExecNotificationQuery
        2. ExecNotificationQueryAsync
      4. Understanding Event Consumers
        1. Creating an Instance of the Consumer
        2. Creating an Event Filter
        3. Creating an Event Query
        4. Binding the Filter to the Consumer
        5. ActiveScriptEventConsumer
      5. Using SMTPEventConsumer
      6. Understanding the New Event Consumers
        1. LogFileEventConsumer
        2. NTEventLogEventConsumer
        3. CommandLineEventConsumer
      7. Working with Different Types of Events
        1. Class Events
        2. Instance Events
        3. Namespace Events
        4. Eventing Events
      8. Summary
      9. Quiz Yourself
      10. On Your Own
        1. Lab 11 Creating a Video Change Notification Script
        2. Lab 12 Expanding the Video Notification Script
  10. Part III: Connect Server and Additional Privileges
    1. Chapter 6: Using the SWbemLocator Methods
      1. Before You Begin
      2. Using the Locator Object
        1. Using Alternate Credentials
      3. Using ConnectServer in Different Ways (1/2)
      4. Using ConnectServer in Different Ways (2/2)
        1. Changing the Defaults
        2. Omitting Fields
      5. Summary
      6. Quiz Yourself
      7. On Your Own
        1. Lab 13 Using the ConnectServer Method Locally
        2. Lab 14 Using Alternate Credentials in a Script
    2. Chapter 7: Requesting Additional Privileges for WMI
      1. Before You Begin
      2. Understanding Privileges
      3. Obtaining a Collection of Privileges
      4. Representing a Single Privilege
      5. Adding Additional Privileges
        1. Adding a Privilege with Add
        2. Adding a Privilege as a String
        3. Using the Item Method
        4. Using the DeleteAll Method
        5. Removing a Specific Privilege
        6. Finding the Most Common Privileges
      6. Using Privileges
        1. In the Moniker
        2. Using SWbemLocator
      7. Summary
      8. Quiz Yourself
      9. On Your Own
        1. Lab 15 Setting the Page File Size
        2. Lab 16 Listing the Working Set
  11. Part IV: Classes
    1. Chapter 8: Understanding WMI Classes
      1. Before You Begin
      2. Using the System Classes
        1. Abstract Base Classes
        2. Using System Classes as Base Classes
        3. Identifying the Version of WMI
        4. Working with System Security
      3. Understanding the CIM Classes
        1. CIM Classes Are Really DMTF Classes
      4. Summary
      5. Quiz Yourself
      6. On Your Own
        1. Lab 17 Exploring Abstract Classes
        2. Lab 18 Examining WMI Classes
    2. Chapter 9: Using Win32 WMI Classes
      1. Before You Begin
      2. Working with Applications (1/2)
      3. Working with Applications (2/2)
        1. Working with Software Classes
        2. Understanding the MSI Installer Provider
      4. Understanding WMI Service Management
        1. Writing to the Properties
      5. Summary
      6. Quiz Yourself
      7. On Your Own
        1. Lab 19 Working with the Win32_Product Class
        2. Lab 20 Making Changes to WMI Settings
    3. Chapter 10: Using System Hardware Classes
      1. Before You Begin
      2. Using Cooling Device Classes
        1. Working with Win32_Fan
        2. Probing the Win32_TemperatureProbe Class
      3. Examining the Input Device Classes
        1. Working with the Win32_Keyboard Class
        2. Working with the Win32_PointingDevice Class
      4. Mass Storage Classes
        1. Checking the Autocheck Settings
        2. Examining the Win32_CDROMDrive Class
        3. Examining the Disk Drive
        4. Examining the Floppy Drive
        5. Working with Tapes
      5. Motherboard, Controller, and Port Classes
        1. Reporting with Port Classes
      6. Networking Device Classes
        1. Working with the Network Adapter Class
        2. Using the Adapter Configuration Class
      7. Power Classes
        1. Batteries Are Included
        2. Using Portable Batteries
      8. Printing Classes
        1. Finding Drivers Used for Print Devices
        2. Printing Information on Printers
        3. Printing the Print Jobs
        4. Working with Printer Ports
      9. Telephony Classes
      10. Video and Monitor Classes
        1. Displaying the Display
        2. Controlling the Video
      11. Summary
      12. Quiz Yourself
      13. On Your Own
        1. Lab 21 Hardware Inventory
    4. Chapter 11: Using Operating System Classes
      1. Before You Begin
      2. Using the COM-Related Classes
        1. Using the Win32_ClassicComClass
      3. Examining the Desktop
      4. Listing the Drivers on a System
        1. Examining System Drivers
      5. Exploring the File System
        1. Working with Directories
        2. Getting the Win32_Directory Class
      6. Understanding Job Objects
        1. Identifying Named Job Objects
        2. Identifying Resources Used by Job Objects
      7. Working with Memory Devices and Page Files
        1. Setting the Page File
      8. Using the Multimedia Audiovisual Class
        1. Retrieving a Single Codec
      9. Working with Networking
      10. Using Operating System Events
      11. Examining Operating System Settings
      12. Employing the Process Classes
        1. Configuring Application Startup
      13. Working with the Registry
        1. Modifying the Registry Size
      14. Leveraging the Scheduler Job Classes
        1. Marking Time
        2. Working with the Job Scheduler
      15. Using the Security Classes
        1. Reading Security on a Folder
      16. Using the Service Classes
        1. Creating a Service
        2. Deleting a Service
      17. Working with Shares
        1. Reporting Connections to the Servers
      18. Starting with the Start Menu
      19. Monitoring Storage
        1. Using the Win32_Volume Methods
      20. Understanding User Classes
        1. Working with Logon Sessions
        2. Working with User Accounts
      21. Leveraging the Windows NT Event Log
        1. Backing Up Event Log Files
      22. Easing Windows Product Activation
      23. Summary
      24. Quiz Yourself
      25. On Your Own
        1. Lab 22 Monitoring the Shutdown of Applications
        2. Lab 23 Performing a Controlled Shutdown of Apps
    5. Chapter 12: Using the Performance Counter Classes
      1. Before You Begin
      2. Using Formatted Performance Counter Classes
        1. Understanding Performance Counter Classes
      3. Refreshing the Data
        1. Using the Refresher Object
        2. Refreshing a Single Counter
        3. Finding How Long Your System Has Been Up
        4. Examining Process Threads
        5. Measuring Memory Utilization
      4. Using Raw Performance Counter Classes
        1. Monitoring Processor Utilization
        2. Working with the Logical Disk
      5. Summary
      6. Quiz Yourself
      7. On Your Own
        1. Lab 24 Working with Formatted Performance Classes
        2. Lab 25 Using Unformatted Performance Counters
  12. Part V: Security and Troubleshooting
    1. Chapter 13: Understanding WMI Security
      1. Before You Begin
      2. Using WMI Namespace Security
        1. Understanding the Defaults
      3. Modifying Security on WMI Namespaces
        1. Working with Namespace Security Descriptors
        2. Using the WMI Control Tool to Set Security
      4. Scripting WMI Namespace Security
        1. Using the __SystemSecurity Class
      5. Working with Share Permissions
        1. Who Has Access to This Share?
        2. Mapping Users and Rights
      6. Summary
      7. Quiz Yourself
      8. On Your Own
        1. Lab 26 Creating a WMI Namespace
        2. Lab 27 Setting WMI Namespace Permissions
    2. Chapter 14: Troubleshooting WMI
      1. Before You Begin
      2. Identifying the Problem
        1. Spotting Common Sources of Errors
      3. Testing the Local WMI Service
        1. Using the WMI Control Tool
        2. Using Scriptomatic
        3. Examining the Status of the WMI Service
        4. Using Wbemtest.exe
      4. Testing Remote WMI Service
        1. Using the WMI Control Tool Remotely
      5. Testing the Scripting Interface
      6. Obtaining Diagnostic Information
        1. Enabling Verbose WMI Logging
        2. Examining the WMI Log Files
        3. Using the Err Tool
        4. Using Mofcomp.exe
        5. Using WMIchk
      7. General WMI Troubleshooting Steps
      8. Summary
      9. Quiz Yourself
      10. On Your Own (1/2)
      11. On Your Own (2/2)
        1. Lab 28 Working with Logging
        2. Lab 29 Compiling MOF Files
  13. Part VI: Appendixes
    1. Appendix A: Scripting API Methods and Properties
    2. Appendix B: WMI Security Constants
    3. Appendix C: WMI Security Privileges and Operations
    4. Appendix D: Computer System Hardware Classes (1/2)
    5. Appendix D: Computer System Hardware Classes (2/2)
    6. Appendix E: Operating System Classes (1/4)
    7. Appendix E: Operating System Classes (2/4)
    8. Appendix E: Operating System Classes (3/4)
    9. Appendix E: Operating System Classes (4/4)
    10. Appendix F: Performance Monitor Classes (1/2)
    11. Appendix F: Performance Monitor Classes (2/2)
  14. Index (1/4)
  15. Index (2/4)
  16. Index (3/4)
  17. Index (4/4)
  18. About the Author

Product information

  • Title: Microsoft® Windows® Scripting with WMI: Self-Paced Learning Guide
  • Author(s): Ed Wilson
  • Release date: October 2005
  • Publisher(s): Microsoft Press
  • ISBN: 9780735622319