![]() |
Table of Contents |
![]() |
How to Use This BookYou can read this book in order from the Introduction to the Appendix. However, if you already have some experience with VBScript, or if you just want to dive right into the more complete example scripts, you can skip around as much as you like. I've organized this book in the same way that I organize my live VBScripting sessions at conferences, so you may feel that it's some time before you really get into the meat of scripting. I assure you, though, that each example in this book-starting in Chapter 1-is focused on Windows administration. You'll get your feet wet right away! I've also included In This Chapter elements at the start of each chapter and Coming Up elements at the end of each chapter. These are brief paragraphs that are intended to help set the stage and help you decide if you need to read a particular chapter or not. They'll also help you decide which chapter to read next based on your individual needs and interests. I hope that these elements-along with the cross-references I've included in each chapter-will help you zip straight to the scripting information that you need most. To help you decide where to start, here's a brief overview of each chapter. Part I: Introduction to Windows Administrative ScriptingPart I serves as an introduction to the world of scripting and provides you with a methodology for approaching administrative tasks from a scripting standpoint. One of the most difficult parts about producing new scripts from scratch is the "Where do I start?" factor, and I'll provide you with a framework for figuring that out every time. Chapter 1: Scripting Concepts and TerminologyAs I've already implied, administrative scripting isn't hard-core programming. Instead, it's using VBScript as a sort of electronic glue to secure various bits of the Windows operating system together. In this chapter, I'll introduce you to those various bits and set the stage with some basic terminology that you'll use throughout this book. Chapter 2: Running ScriptsWriting a script isn't much fun if you can't run the script, and so this chapter will focus on the technologies used to execute scripts. You might be surprised to learn how many different Microsoft products support scripting. In this chapter, I'll show you how far your scripting skills can really take you. I'll also introduce you to some scripting tools that can make writing and debugging scripts a bit easier. Chapter 3: The Components of a ScriptIn this chapter, I'll present a complete administrative script, and then break it down line-by-line to explain its various components. Although this chapter isn't necessary to learning administrative scripting, it will help you write scripts that are more reliable and easier to troubleshoot. Chapter 4: Designing a ScriptAs I've mentioned already, one of the toughest aspects about scripting can be figuring out where to start. In this chapter, I'll provide you with a framework that you can use as a starting point for every new scripting project. I'll also introduce you to some concepts that many scripting books ignore, such as planning for errors and creating a useful "resource kit" of script components that you can reuse throughout your scripting projects. Part II: VBScript TutorialHere's your official crash course to the VBScript language: just enough to make administration via script a possibility! The best part is that I won't use the trite "Hello, world" examples that books for software developers often start out with. Instead, I'll make every example useful to you as a Windows administrator. That means you'll be producing simple, useful scripts at the same time you're learning VBScript. What could be better? Chapter 5: Functions, Objects, Variables, and MoreIn this chapter, I'll show you the basic building blocks of any script and introduce you to some sample scripts that use each building block in a particular administrative task. This is really the meat of administrative scripting, and you'll be able to write useful scripts when you're finished with this chapter. Chapter 6: Input and OutputYou can make your scripts more flexible by adding the ability to dynamically change computer, user, and domain names, along with other information. In this chapter, I'll show you how your script can collect information it needs to run and dynamically alter itself to take advantage of that information. Chapter 7: Manipulating NumbersThis chapter will explain how scripts can manipulate numbers, making it easier to create scripts that work with numeric data, such as user account data. I'll also introduce you to VBScript's numeric data handling and conversion commands, putting you on the path to some great scripting techniques. Chapter 8: Manipulating StringsStrings-a fancy word for text data-are at the heart of most scripting tasks. In this chapter, I'll show you how VBScript deals with strings and how you can easily integrate them into your scripts. Chapter 9: Manipulating Other Types of DataAside from text and numbers, your scripts may need to deal with dates, times, bytes, and other forms of data to accomplish specific administrative tasks. In this chapter, I'll show you how VBScript handles these other data types and how you can use them in your own scripts. Chapter 10: Controlling the Flow of ExecutionThe best administrative scripts can respond to changing conditions with internal logic, called control-of-flow. In this chapter, I'll show you how your scripts can be made to evaluate various conditions and respond accordingly, perform repetitive tasks, and much more. Chapter 11: Built-in Scripting ObjectsMuch of VBScript's power comes from its capability to join various operating system objects, and in this chapter, I'll introduce you to your first set of those objects. You'll learn how to manipulate network information, map drives, and much more-pretty much everything you need to write effective logon scripts. Chapter 12: Working with the File SystemA common use of scripting is to manipulate files and folders, and in this chapter, I'll introduce you to the VBScript FileSystemObject, which provides a complete object model for working with the file system. You'll learn to build a utility that scans IIS log files for error messages, a useful script for any environment! Chapter 13: Putting It All Together: Your First ScriptThis is where you'll put everything from Part II together. You'll be creating a script that rotates IIS log files, keeping the past 30 days' worth of files in a special archive folder. I'll guide you through the complete process of designing, writing, testing, and troubleshooting the script. In fact, I'll deliberately introduce some logic errors into the script so that you can see the debugging process in action. Part III: Windows Management Instrumentation and Active Directory Services InterfaceWith the glue of VBScript under your belt, I'll dive into the two most powerful technologies for administering Windows: Windows Management Instrumentation (WMI) and the Active Directory Services Interface (ADSI). These technologies provide administrative access to, and control over, nearly every aspect of the Windows operating system, from Windows NT to Windows Server 2003. Chapter 14: Working with ADSI ProvidersDespite its name, ADSI isn't just for Active Directory. In this chapter, I'll show you how ADSI can be used to interface with NT, Active Directory, Novell NDS, Exchange Server, and other types of directory services. I'll provide some basic examples of the types of tasks you can perform with ADSI to get you started. Chapter 15: Manipulating DomainsWith the ADSI basics out of the way, I'll focus on manipulating domain information in a script. You'll learn how to query domain information, modify domain policies like password length, and much more. Chapter 16: Manipulating Users and GroupsIn this chapter, you'll learn how to write scripts that query and modify user and group information. This is one of the most common tasks you'll perform with VBScript, and I'll include plenty of useful examples. Chapter 17: Understanding WMIWMI provides a hook into just about every portion of the Windows operating system, making it an incredibly useful tool for administrative scripts. In this chapter, I'll introduce you to WMI and show you a preview of what you can use it for in your environment. Chapter 18: Querying Basic WMI InformationDo you want to find out which users in your organization have a Pentium 4 computer? This chapter will show you how to write your own basic WMI queries, including those that involve remote machines. You'll also learn basic WMI manipulation, which lets you modify local and remote machine settings from within a script. Chapter 19: Querying Complex WMI InformationSome WMI queries are more complex, such as querying the IP addresses from multiple network adapters in multiple remote computers. This chapter provides clear examples of these more complex WMI tasks, helping you learn to write enterprise management scripts. Chapter 20: Putting It All Together: Your First WMI/ADSI ScriptThis is where it all comes together. I'll walk you through the process of designing, writing, testing, and debugging a complete WMI/ADSI script from scratch. You'll finish this chapter with a concrete example of the administrative capabilities of these technologies, and then you'll be ready to start writing your own scripts. Part IV: Creating Administrative Web PagesOne popular use of Web technologies inside corporate networks is to provide user self-service pages, such as a simple Web page where users can reset their own passwords, if necessary. In Part IV, I'll give you a crash course on IIS and Active Server Pages (ASP) and show you how to start building your own administrative Web pages. Chapter 21: Active Server Pages Crash CourseASP is a great way to create effective administrative Web pages. I'm not going to try to make you a Web developer or an HTML expert; the Web pages you'll create in this chapter won't be pretty, but they'll be incredibly effective. Chapter 22: Adding Administrative Script to a Web PageAfter you have a basic Web page ready, you can start adding script to it to make the Web page perform administrative tasks. I'll provide examples of real-world tasks that you can start using in your environment right away. Chapter 23: Web Page Security OverviewWeb pages have special security concerns, which I'll focus on in this chapter. I'll explain how IIS 5.0 and 6.0 process Web pages, what you can and cannot easily accomplish from within a Web page, and how you can create a secure, stable environment for Web-based administrative scripts. Chapter 24: Putting It All Together: Your First Administrative Web PageYou're now ready to design, write, run, test, and debug your own administrative Web pages, and in this chapter, I'll step you through the entire progression. When you're finished, you'll not only have a ready-to-run administrative Web page to use, you'll also be ready to start creating your own Web pages from scratch. Again, they might not be pretty, but they'll be incredibly functional and useful. Part V: Advanced Scripting TechniquesAs you become a more experienced scripter, you'll be ready to start saving time and be more secure, with advanced techniques like script encryption, scripting components, script security, and so forth. In this part of the book, I'll give you a comprehensive look at each of these technologies and show you how to put them into use in your own environment. Chapter 25: Modular Script ProgrammingIf you find yourself cutting and pasting code-or worse, retyping it-this is the chapter for you. I'll introduce you to modular scripting concepts, which make it easier to reuse code between various scripts, saving you time and effort! By way of example, we'll start with a complex script that contains lots of useful code, and then break it down into easily reused modules. Chapter 26: Using Script ComponentsWindows Script Components are the easy way to create your own fully encapsulated chunks of script, each of which performs a useful task. Building on the examples in Chapter 25, I'll show you how to create and use script components to make administrative scripting faster and easier. You'll come away with a whole library of script components that you can start using immediately! Chapter 27: Encoded ScriptsAre you worried that others will peek into your scripts and steal your ideas? Scripting encryption helps protect your scripts from both Peeping Toms and potential misuse, so I'll show you how to set up, deploy, and use script encryption within your environment in this chapter. Chapter 28: Scripting SecuritySome folks think Microsoft made a huge mistake when it included VBScript in the Windows operating system, but I disagree. Properly configured, scripting can be as safe as any other type of application. In this chapter, I'll explain scripting security concepts and introduce you to the tools that can make scripting a safe and valuable part of any computing environment. Part VI: Ready-to-Run ExamplesI figured a great way to wrap up the book would be a whole section on ready-made example scripts that you can start using in your own environment. Additionally, these scripts-like every other script in this book-will have complete, line-by-line explanations, making them a perfect reference guide as you start to create your own scripts from scratch. Chapter 29: Logon and Logoff ScriptsI'll use this chapter to present more complex logon and logoff scripts and to give you some ideas for how scripting can make these important scripts more effective. Of course, the line-by-line explanations will make each script a useful reference for customizing your own scripts. Chapter 30: Windows and Domain Administration ScriptsAutomating domain administration is probably one of the big reasons you started looking at scripting in the first place, so I'll use this chapter to present a number of examples of tasks that scripts can perform. The detailed explanations with each script will help you rip them apart and customize them for your own use. Chapter 31: Network Administration ScriptsNetwork administration is ideally suited for scripting, and in this chapter, I'll provide a handful of examples that will show you what's possible. The line-by-line explanations will make it easy to put these into use in your own environment. Chapter 32: WMI and ADSI ScriptsThese can be the toughest scripts to write due to the complexity and flexibility of WMI and ADSI. In this chapter, I'll provide you with several ready-to-use scripts for common tasks like querying WMI, creating users and groups, and more. These scripts can be easily modified and incorporated into your own scripts, saving you scripting time! Part VII: AppendixAppendix: Administrator's Quick Script ReferenceOne of the toughest parts about VBScript is that it contains so much functionality. It's usually pretty easy to figure out what you want a script to do; the tough part is often figuring out how to make VBScript do it! In this appendix, I'll provide you with an alphabetical list of common tasks and give the VBScript commands that perform each task. You can use this reference along with the VBScript documentation to make designing and writing scripts much easier. |
![]() |
Table of Contents |
![]() |