Previous Page
Next Page

Introduction

Network administrators and consultants are confronted with numerous mundane and timeconsuming activities on a daily basis. Whether it is going through thousands of users in Active Directory Users and Computers to grant dial-in permissions to a select group, or changing profile storage locations to point to a newly added network server, these everyday tasks must be completed. In the enterprise space, the ability to quickly write and deploy a Microsoft Visual Basic Script (VBScript) will make the difference between a task that takes a few hours and one that takes a few weeks.

As an Enterprise Consultant for Microsoft Corporation, I am in constant contact with some of the world's largest companies that run Microsoft software. The one recurring theme I hear is, "How can we effectively manage thousands of servers and tens of thousands of users?" In some instances, the solution lies in the employment of specialized software packagesbut in the vast majority of the cases, the solution is a simple VBScript.

In Microsoft Windows Server 2003, enterprise manageability was one of the design goals, and VBScript is one path to unlocking the rich storehouse of newly added features. Using the techniques outlined in Microsoft VBScript Step by Step, anyone can begin crafting custom scripts within minutes of opening these pages. I'm not talking about the traditional Hello World scriptI'm talking about truly useful scripts that save time and help to ensure accurate and predictable results.

Whereas in the past scripting was somewhat hard to do, required special installations of various implementations, and was rather limited in its effect, with the release of Microsoft Windows XP, Windows Server 2003, and Windows Vista, scripting is coming into its own. This is really as it should be. However, most administrators and IT professionals do not have an understanding of scripting because in the past scripting was not a powerful alternative for platform management.

However, in a large enterprise, it is a vital reality that one simply cannot perform management from the GUI applications because it is too time-constraining, too error prone, and, after a while, too irritating. Clearly there needs to be a better way, and there is. Scripting is the answer.

A Practical Approach to Scripting

Microsoft VBScript Step by Step will equip you with the tools to automate setup, deployment, and management of Microsoft Windows 2003 networks via the various scripting interfaces contained within the product. In addition, it will provide you with an understanding of a select number of VBScripts adaptable to your own unique environments. This will lead you into an awareness of the basics of programming through modeling of fundamental techniques.

The approach I take to teaching you how to use VBScript to automate your Windows 2003 servers is similar to the approach used in some executive foreign language schools. You'll learn by using the language. In addition, concepts are presented not in a dry academic fashion, but in a dynamic, real-life manner. When a concept is needed to accomplish something, it is presented. If a topic is not useful for automating network management, I don't bring it forward.

This is a practical, application-oriented book, so the coverage of VBScript, Windows Scripting Host, Active Directory Service Interfaces (ADSI), and Windows Management Instrumentation (WMI) is not exceedingly deep. This is not a reference book; it is a tutorial, a guidea spring-board for ideas, perhapsbut not an encyclopedia.

Is This Book for Me?

Microsoft VBScript Step by Step is aimed at several audiences, including:

  • Windows networking consultants Anyone desiring to standardize and automate the installation and configuration of .NET networking components.

  • Windows network administrators Anyone desiring to automate the day-to-day management of Windows .NET networks.

  • Windows Help Desk staff Anyone desiring to verify configuration of remotely connected desktops.

  • Microsoft Certified Systems Engineers (MCSEs) and Microsoft Certified Trainers (MCTs) Although scripting is not a strategic core competency within the MCP program, a few questions about scripting do crop up from time to time on various exams.

  • General technical staff Anyone desiring to collect information, configure settings on Windows XP machines, or implement management via WMI, WSH, or WBEM.

  • Power users Anyone wishing to obtain maximum power and configurability of their Windows XP machines either at home or in an unmanaged desktop workplace environment.

Outline of This Book

This book is divided into four parts, each covering a major facet of scripting. The following sections describe these parts.

Part I: Covering the Basics

Okay, so you've decided you need to learn scripting. Where do you begin? Start here in Part I! In Chapter 1, "Starting From Scratch," you learn the basics: what a script is, how to read it, and how to write it. Once you move beyond using a script to figure out what your IP address is and print it to a file, you need to introduce some logic into the script, which you do in Chapter 2 through Chapter 5. You'll learn how to introduce conditions and add some intelligence to allow the script to check some stuff, and then based upon what it finds, do some other stuff. This section concludes by looking at troubleshooting scripts. I've made some mistakes that you don't need to repeat! Here are the chapters in Part I:

Part II: Basic Windows Administration

In Part II, you dig deep into VBScript and WMI and really begin to see the power you can bring to your automation tasks. In working with the file system, you see how to use the file system object to create files, delete files, and verify the existence of files. All these basic tasks provide loads of flexibility for your scripts. Next, you move on to working with folders, learning how to use VBScript to completely automate the creation of folders and files on your servers and users' workstations. In the last half of Part II, you get an in-depth look at the power of WMI when it is combined with the simplicity and flexibility of VBScript. Here are the chapters in Part II:

Part III: Advanced Windows Administration

This section will shave at least four points off your golf handicap because you'll get to play an extra 18 holes a week due to the time you'll save! At least three things are really painful when it comes to administering Windows servers: all those click, click, and save motions; all the time spent waiting for the screen to refresh; and loosing your place in a long list of users. Guess what? In this section, some of that pain is relieved. When Human Resources hires 100 people, you tell them to send you a spreadsheet with the new users, and then use a script to create those users. It takes 2 minutes instead of 2 hours. (Dude, that's the front nine!) In addition to saving time, scripting your administrative tasks reduces the likelihood of errors. If you have to set a particular set of access control lists on dozens of folders, a script is the only way to ensure all the flags are set correctly. Here are the chapters in Part III:

Part IV: Scripting Other Applications

Once you learn how to use WMI and VBScript to automate Windows Server 2003, the logical question is, "What else can I do?" Well, with the latest version of Microsoft Exchange and Internet Information Services (IIS), the answer is, "Quite a lot." So in this part of the book, you look at using WMI and VBScript to automate other applications.

In IIS 6.0, nearly everything that can be configured via GUI tools can also be scripted. This enables the Web administrator to simplify management and to also ensure repeatable configuration of the Web sites from a security perspective.

In Exchange administration, many routine tasks can be simplified by using VBScript. In Part IV, you look at how to leverage the power of VBScript to simplify user management, to configure and administer Exchange, and to troubleshoot some of the common issues confronting the enterprise Exchange administrator. The chapters in Part IV are as follows:

Part V: Appendices

The appendices in this book are not the normal "never read" stuff. Indeed, you will find yourself referring again and again to these five crucial documents. In Appendix A you will find lots of ideas for further work in developing your mastery of VBScript. Appendix B will save you many hours of searching for the "special names" that unlock the power of ADSI scripting. Appendix C helps you find the special WMI namespaces that enable you to perform many cool "tricks" in your scripting. And last but certainly not least is Appendix D, which contains my documentation "cheat sheet." Actually, you will want to read it rather early in your scripting career. Appendix E contains the Special Folder Constants, which, as you will see in the very first script in the book, can provide easy access to some of the most vital folders on your workstation!

Finding Your Best Starting Point

This book will help you add essential skills for using VBScript to automate your Windows environment. You can use this book if you are new to scripting, new to programming, or switching from another scripting language. The following table will assist you in picking the best starting point in the book.

If you are

Follow these steps

New to programming

Install the practice files as described in the section "Installing the Practice Files on Your Computer" later in this Introduction.

 

Learn the basic skills for using VBScript by working through Chapters 1-7 in order.

New to VBScript

Install the practice files as described in the section "Installing the Practice Files on Your Computer" later in this Introduction.

 

Skim through Chapter 1, making sure you pay attention to the section on creating objects.

 

Skim Chapter 2 and Chapter 3.

 

Complete Chapter 4 through Chapter 7 in order.

Experienced with VBScript but are interested in using WMI

Install the practice files as described in the section "Installing the Practice Files on Your Computer" later in this Introduction.

 

Skim Chapter 4, paying attention to handling arrays.

 

Work through Chapters 8-10 in order. Complete Chapter 14.


About the Companion CD

The CD accompanying this book contains additional information and software components, including the following files:

  • Sample Files The chapter folders contain starter scripts, some text files, and completed solutions for each of the procedures contained in this book. In addition, each of the scripts discussed in the book is contained in the folder corresponding to the chapter number. For instance, in Chapter 1 we talk about enumerating disk drives on a computer system. The script that makes up the bulk of our discussion around that topic is contained in the \My Documents\Microsoft Press\VBScriptSBS\ch01 folder. You'll also find many bonus scripts in the chapter folders. In addition to the sample files in the chapter folders, the CD includes a Templates folder, a Resources folder, a Supplemental folder, and a Utilities folder. These folders contain dozens of my favorite scripts and utilities I have written over the last several years to solve literally hundreds of problems. You will enjoy playing around with these and incorporating them into daily scripting tasks. For example, in the Templates folder you will find my WMITemplate.vbs script. By using it as a starter, you can write a custom WMI script in less than five seconds. By using the ADOSearchTemplate.vbs script as a starter, you can write a script that returns all the users in a particular OU in less than three seconds. In the Utilities folder you will find, for example, a script that converts bytes into kilobytes, megabytes, or gigabytes depending on the largest whole number that can be so created.

  • eBook You can view an electronic version of this book on screen using Adobe Acrobat Reader. For more information, see the Readme.txt file included in the root folder of the Companion CD.

  • Tools and Resources Additional tools and resources to make scripting faster and easier: Scriptomatic 2.0, Tweakomatic, EZADScriptomatic, WMI Admin Tools, WMI CodeCreator, WMI Diag.

Installing the Practice Files on Your Computer

Follow these steps to install the practice files on your computer so that you can use them with the exercises in this book.

1.
Remove the companion CD from the package inside this book and insert it into your CD-ROM drive.

Note

An end user license agreement should open automatically. If this agreement does not appear, open My Computer on the desktop or Start menu, double-click the icon for your CD-ROM drive, and then double-click StartCD.exe.

2.
Review the end user license agreement. If you accept the terms, select the accept option and then click Next.

A menu will appear with options related to the book.

3.
Click Install Code Samples.

4.
Follow the instructions that appear.

The code samples are installed to the following location on your computer:

My Documents\Microsoft Press\VBScriptSBS\

Uninstalling the Practice Files

Follow these steps to remove the practice files from your computer.

1.
In the Control Panel, open Add Or Remove Programs.

2.
From the list of Currently Installed Programs, select Microsoft VBScript Step by Step.

3.
Click Remove.

4.
Follow the instructions that appear to remove the code samples.

System Requirements

  • Special Folder Constants

  • Minimum 233 MHz in the Intel Pentium/Celeron family or the AMD k6/Atholon/Duron family

  • 64 MB memory

  • 1.5 GB available hard disk space

  • Display monitor capable of 800 x 600 resolution or higher

  • CD-ROM drive or DVD drive

  • Microsoft Mouse or compatible pointing device

  • Windows Server 2003, Windows XP, or Windows Vista

  • The MSI Provider installed on Windows Server 2003 (required for some of the WMI procedures)

  • Microsoft Office Excel or Excel Viewer

Technical Support

Every effort has been made to ensure the accuracy of this book and the contents of the companion CD-ROM. Microsoft Press provides corrections for books through the World Wide Web at http://www.microsoft.com/learning/support.

To connect directly with the Microsoft Press Knowledge Base and enter a query regarding a question or an issue that you might have, go to http://www.microsoft.com/learning/support/search.asp.

If you have comments, questions, or ideas regarding this book or the companion CD-ROM, please send them to Microsoft Press using either of the following methods:

E-mail:

msinput@microsoft.com

Postal Mail:

Microsoft Press
Attn: Editor, Microsoft VBScript Step by Step
One Microsoft Way
Redmond, WA 980526399

Please note that product support is not offered through the preceding addresses.

For additional support information regarding this book and the CD-ROM (including answers to commonly asked questions about installation and use), visit the Microsoft Press Technical Support Web site at www.microsoft.com/learning/support/books/. For support information regarding Microsoft software, please connect to http://support.microsoft.com.


Previous Page
Next Page