Next Section

Managing Windows® with VBScript and WMI

"Finally, a step-by-step VBScripting book to make you look like a programmer without the time and sweat! Don't waste your time searching the Internet for examples-this book does it for you!"
-Greg A. Marino, Senior Systems Engineer/Consultant, Westtown Consulting Group, Inc.

Visual Basic Scripting (VBScript) and Windows Management Instrumentation (WMI) are vital tools for systems administrators grappling with the increasing complexity of Windows technologies. However, busy admins have been without a straightforward guide to scripting...until now.

Managing Windows(R) with VBScript and WMI explains how Windows administrators can effectively use VBScript to automate common administrative tasks and simplify complex ones. Detailed coverage of security concerns provides admins with the means for safely using VBScript in Windows environments. The book is organized around the problems you face daily, with reusable examples and coverage of Windows NT, Windows 2000, Windows XP, and Windows 2003.

This user-friendly reference demystifies scripting and then shows you how to produce new scripts from scratch. You will be producing useful scripts right away as you study the VBScript language and learn how to control nearly every aspect of the Windows operating system with WMI and the Active Directory Services Interface (ASDI). You will be able to build your own administrative Web pages and use advanced scripting technologies such as script encryption, scripting components, and script security. The book closes with still more ready-made example scripts accompanied by complete line-by-line explanations. The CD includes all the code from the book and trial versions of PrimalScript 3.0 and VbsEdit. A companion Web site provides updates and errata.

Inside you will find answers to such questions as:


Table of Contents

   Praise for Managing Windows ® with VBScript and WMI
   Preface
     Who Should Read This Book?
     How to Use This Book
     Preparing to Use This Book
     Typographical Elements
   Acknowledgments
   About the Author
    Part I:  Introduction to Windows Administrative Scripting
       Chapter 1.  Scripting Concepts and Terminology
     What Is Scripting?
     Script Hosts
     ActiveX Scripting Languages
     The Component Object Model ( COM )
     Critical Scripting Security Issues
     Review
       Chapter 2.  Running Scripts
     Windows Script Host
     Command-Line Scripts
     Notepad and Script Editors
     Writing Your First Script
     Running Your First Script
     Debugging Your First Script
     Review
       Chapter 3.  The Components of a Script
     A Typical VBScript
     Functions
     Subroutines
     Main Script
     Comments and Documentation
     Review
       Chapter 4.  Designing a Script
     Creating a Task List
     Selecting the Appropriate Tools
     Creating Modules to Perform Tasks
     Validating User Input
     Planning for Errors
     Creating Script Libraries
     Review
    Part II:  VBScript Tutorial
       Chapter 5.  Functions, Objects, Variables, and More
     What Are Variables?
     What Are Functions?
     What Are Statements and Subroutines?
     What Are Objects?
     Review
       Chapter 6.  Input and Output
     Displaying Messages
     Asking for Input
     Command-Line Parameters as Input
     Review
       Chapter 7.  Manipulating Numbers
     Numbers in VBScript
     Basic Arithmetic
     Advanced Arithmetic
     Boolean Math
     Converting Numeric Data Types
     Converting Other Data Types to Numeric Data
     Review
       Chapter 8.  Manipulating Strings
     Strings in VBScript
     Working with Substrings
     Concatenating Strings
     Changing Strings
     Formatting Strings
     Converting Other Data Types to String Data
     Review
       Chapter 9.  Manipulating Other Types of Data
     Working with Dates and Times
     Working with Arrays
     Working with Bytes
     Review
       Chapter 10.  Controlling the Flow of Execution
     Conditional Execution
     Loops
     Putting It All Together
     Review
       Chapter 11.  Built-in Scripting Objects
     The WScript Object
     The Network Object
     The Shell Object
     The Shortcut Object
     Review
       Chapter 12.  Working with the File System
     The FileSystemObject Library
     Working with Drives
     Working with Folders
     Working with Files
     Reading and Writing Text Files
     Other FSO Methods and Properties
     Creating a Log File Scanner
     Review
       Chapter 13.  Putting It All Together: Your First Script
     Designing the Script
     Writing Functions and Subroutines
     Writing the Main Script
     Testing the Script
     Review
    Part III:  Windows Management Instrumentation and Active Directory Services Interface
       Chapter 14.  Working with ADSI Providers
     Using ADSI Objects
     Using the WinNT Provider
     Using the LDAP Provider
     Other Providers
     Review
       Chapter 15.  Manipulating Domains
     Querying Domain Information
     Changing Domain Settings
     Working with OUs
     Putting It All Together
     Review
       Chapter 16.  Manipulating Users and Groups
     Creating Users and Groups
     Querying User Information
     Changing User Settings
     Working with Groups
     Putting It All Together
     Review
       Chapter 17.  Understanding WMI
     The WMI Hierarchy
     Exploring WMI's Capabilities
     Installing WMI
     Using the WMI Tools
     Really—It's This Easy
     Review
       Chapter 18.  Querying Basic WMI Information
     The WMI Query Language ( WQL )
     Determining What to Query
     Testing the Query
     Writing the Query in VBScript
     Using the Query Results
     Alternative Methods
     Review
       Chapter 19.  Querying Complex WMI Information
     Understanding WMI Relationships
     Associating WMI Instances
     Writing the Query
     Testing the Query
     Writing the Query in VBScript
     Another Example
     Review
       Chapter 20.  Putting It All Together: Your First WMI/ADSI Script
     Designing the Script
     Writing Functions and Subroutines
     Writing the Main Script
     Testing the Script
     Review
    Part IV:  Creating Administrative Web Pages
       Chapter 21.  Active Server Pages Crash Course
     About ASP
     VBScript in ASP
     The Response Object
     The Request Object
     A Sample ASP Script
     Testing ASP Scripts
     Review
       Chapter 22.  Adding Administrative Script to a Web Page
     The Basic Web Page
     Adding Functions and Subroutines
     Adding Inline Script
     The Result
     Review
       Chapter 23.  Web Page Security Overview
     The ASP Security Context
     Prohibited Behaviors
     IIS 4.0, 5.0, and 5.1 versus IIS 6.0
     NTFS and IIS Security
     Writing Secure ASP Code
     Review
       Chapter 24.  Putting It All Together: Your First Administrative Web Pages
     Checking User Account Status
     Administering IIS
     Review
    Part V:  Advanced Scripting Techniques
       Chapter 25.  Modular Script Programming
     Introduction to Windows Script Components
     Scripting and XML
     Review
       Chapter 26.  Using Script Components
     Obtaining the Component
     Reviewing the Component
     Using the Component
     Review
       Chapter 27.  Encoded Scripts
     Installing the Script Encoder
     Writing Encoded Scripts
     Running Encoded Scripts
     Review
       Chapter 28.  Scripting Security
     Why Scripting Can Be Dangerous
     Security Improvements in Windows XP and Windows Server 2003
     Digitally Signing Scripts
     Running Only Signed Scripts
     Ways to Implement Safe Scripting
     Review
    Part VI:  Ready-to-Run Examples
       Chapter 29.  Logon and Logoff Scripts
     NT and Active Directory Logon Scripts
     Active Directory–Specific Logon Scripts
     Active Directory Logoff Scripts
     Review
       Chapter 30.  Windows and Domain Administration Scripts
     Automating User Creation
     Finding Inactive Users
     Collecting System Information
     Review
       Chapter 31.  Network Administration Scripts
     Shutting Down Remote Computers
     Listing Remote Shares
     Finding Out Who Has a File Open
     Uninstall Remote MSI Packages
     Adding Users from Excel
     Listing Hot Fixes and Software
     Review
       Chapter 32.  WMI and ADSI Scripts
     The All-Purpose WMI Query Script
     The All-Purpose WMI Update Script
     The All-Purpose ADSI Object Creation Script
     The All-Purpose ADSI Object Query Script
     The All-Purpose ADSI Object Deletion Script
     Mass Password Changes with ADSI
     Review
    Part VII:  Appendix
       Administrator's Quick Script Reference
     A
     B
     C
     D
     E
     F
     G
     H
     I
     J
     K
     L
     M
     N
     O
     P
     Q
     R
     S
     T
     U
     V
     W
    Next Section