Managing Windows with VBscript and WMI

Managing Windows with VBscript and WMI

by Don Jones
     
 

ISBN-10: 0321213343

ISBN-13: 9780321213341

Pub. Date: 03/26/2004

Publisher: Addison-Wesley

"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

Overview

"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® 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:

  • How do you write effective logon scripts? Chapter 11
  • How do you write scripts that query and modify user and group information? Chapter 16
  • How can you query the IP addresses from multiple network adapters in multiple remote computers? Chapter 19
  • How can you design, write, run, test, and debug your own administrative Web pages? Chapter 24
  • How can you reuse code between various scripts? Chapter 25

Product Details

ISBN-13:
9780321213341
Publisher:
Addison-Wesley
Publication date:
03/26/2004
Series:
Microsoft Windows Server System Series
Pages:
601
Product dimensions:
6.98(w) x 9.20(h) x 1.27(d)

Table of Contents

Prefacexxi
Acknowledgmentsxxxv
About the Authorxxxvii
Part IIntroduction to Windows Administrative Scripting1
Chapter 1Scripting Concepts and Terminology3
What Is Scripting?3
Script Hosts4
ActiveX Scripting Languages6
The Component Object Model (COM)9
Critical Scripting Security Issues9
Review10
Chapter 2Running Scripts11
Windows Script Host11
Command-Line Scripts13
Notepad and Script Editors16
Writing Your First Script23
Running Your First Script25
Debugging Your First Script25
Review26
Chapter 3The Components of a Script29
A Typical VBScript29
Functions32
Subroutines33
Main Script34
Comments and Documentation40
Review45
Chapter 4Designing a Script47
Creating a Task List48
Selecting the Appropriate Tools50
Creating Modules to Perform Tasks57
Validating User Input63
Planning for Errors63
Creating Script Libraries66
Review66
Part IIVbscript Tutorial69
Chapter 5Functions, Objects, Variables, and More71
What Are Variables?72
What Are Functions?82
What Are Statements and Subroutines?89
What Are Objects?92
Review97
Chapter 6Input and Output99
Displaying Messages99
Asking for Input107
Command-Line Parameters as Input110
Review114
Chapter 7Manipulating Numbers117
Numbers in VBScript117
Basic Arithmetic118
Advanced Arithmetic121
Boolean Math124
Converting Numeric Data Types129
Converting Other Data Types to Numeric Data130
Review130
Chapter 8Manipulating Strings133
Strings in VBScript133
Working with Substrings135
Concatenating Strings139
Changing Strings141
Formatting Strings143
Converting Other Data Types to String Data144
Review145
Chapter 9Manipulating Other Types of Data147
Working with Dates and Times147
Working with Arrays150
Working with Bytes155
Review156
Chapter 10Controlling the Flow of Execution157
Conditional Execution158
Loops164
Putting It All Together170
Review173
Chapter 11Built-in Scripting Objects175
The WScript Object175
The Network Object176
The Shell Object183
The Shortcut Object190
Review192
Chapter 12Working with the File System193
The FileSystemObject Library193
Working with Drives194
Working with Folders197
Working with Files204
Reading and Writing Text Files207
Other FSO Methods and Properties211
Creating a Log File Scanner212
Review221
Chapter 13Putting It All Together: Your First Script223
Designing the Script224
Writing Functions and Subroutines227
Writing the Main Script232
Testing the Script240
Review251
Part IIIWindows Management Instrumentation and Active Directory Services Interface253
Chapter 14Working with ADSI Providers255
Using ADSI Objects255
Using the WinNT Provider257
Using the LDAP Provider260
Other Providers263
Review263
Chapter 15Manipulating Domains265
Querying Domain Information265
Changing Domain Settings267
Working with OUs268
Putting It All Together273
Review279
Chapter 16Manipulating Users and Groups281
Creating Users and Groups281
Querying User Information284
Changing User Settings285
Working with Groups286
Putting It All Together288
Review292
Chapter 17Understanding WMI293
The WMI Hierarchy293
Exploring WMI's Capabilities296
Installing WMI301
Using the WMI Tools302
Really--It's This Easy304
Review309
Chapter 18Querying Basic WMI Information311
The WMI Query Language (WQL)311
Determining What to Query316
Testing the Query319
Writing the Query in VBScript321
Using the Query Results326
Alternative Methods328
Review329
Chapter 19Querying Complex WMI Information331
Understanding WMI Relationships331
Associating WMI Instances336
Writing the Query340
Testing the Query341
Writing the Query in VBScript341
Another Example345
Review349
Chapter 20Putting It All Together: Your First WMI/ADSI Script351
Designing the Script351
Writing Functions and Subroutines357
Writing the Main Script360
Testing the Script369
Review374
Part IVCreating Administrative Web Pages375
Chapter 21Active Server Pages Crash Course377
About ASP378
VBScript in ASP379
The Response Object381
The Request Object384
A Sample ASP Script385
Testing ASP Scripts389
Review391
Chapter 22Adding Administrative Script to a Web Page393
The Basic Web Page393
Adding Functions and Subroutines396
Adding Inline Script397
The Result403
Review417
Chapter 23Web Page Security Overview419
The ASP Security Context419
Prohibited Behaviors423
IIS 4.0, 5.0, and 5.1 versus IIS 6.0424
NTFS and IIS Security427
Writing Secure ASP Code427
Review431
Chapter 24Putting It All Together: Your First Administrative Web Pages433
Checking User Account Status433
Administering IIS443
Review460
Part VAdvanced Scripting Techniques461
Chapter 25Modular Script Programming463
Introduction to Windows Script Components463
Scripting and XML465
Review474
Chapter 26Using Script Components475
Obtaining the Component475
Reviewing the Component476
Using the Component477
Review479
Chapter 27Encoded Scripts481
Installing the Script Encoder482
Writing Encoded Scripts482
Running Encoded Scripts485
Review486
Chapter 28Scripting Security487
Why Scripting Can Be Dangerous487
Security Improvements in Windows XP and Windows Server 2003488
Digitally Signing Scripts490
Running Only Signed Scripts493
Ways to Implement Safe Scripting494
Review495
Part VIReady-to-Run Examples497
Chapter 29Logon and Logoff Scripts499
NT and Active Directory Logon Scripts500
Active Directory-Specific Logon Scripts507
Active Directory Logoff Scripts513
Review516
Chapter 30Windows and Domain Administration Scripts517
Automating User Creation517
Finding Inactive Users527
Collecting System Information533
Review539
Chapter 31Network Administration Scripts541
Shutting Down Remote Computers541
Listing Remote Shares544
Finding Out Who Has a File Open547
Uninstall Remote MSI Packages549
Adding Users from Excel553
Listing Hot Fixes and Software562
Review566
Chapter 32WMI and ADSI Scripts567
The All-Purpose WMI Query Script567
The All-Purpose WMI Update Script569
The All-Purpose ADSI Object Creation Script571
The All-Purpose ADSI Object Query Script572
The All-Purpose ADSI Object Deletion Script573
Mass Password Changes with ADSI574
Review576
Part VIIAppendix577
AppendixAdministrator's Quick Script Reference579
Index591

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >