Use scripts to automate tedious tasks
If your job as a Windows NT systems administrator never gets any easier, you need to find ways to work smarter and be more efficient. Consider the many tasks that you perform. Would writing scripts to automate certain tasks be helpful? If you have a simple task that you need to perform only once, writing a script to automate that task isn't very beneficial. Writing the script would probably take longer than manually executing the task. However, if you perform a task repeatedly (such as continually rewriting similar code fragments or maintaining numerous configuration files), you can develop common scripting solutions that will save you time and effort down the road.
For example, suppose you become the Windows Scripting Host (WSH) and Visual Basic Script (VBScript) guru at work. You develop a dozen scripts that execute tasks on various types of servers. Each script requires an input file that lists the servers on which the script runs. When you add servers to your environment or change the configuration of existing servers, you must revisit each input file to ensure its accuracy. This task becomes tedious because you must keep track of hundreds of servers.
How can you work smarter? You have several possibilities, all of which involve using one input file that includes all servers. What differs is how you write that input file. You can use a Perl/Tk multiselect list box. You can use an INI file format in which the configuration file contains a section for each system type. Or, you can use an integer identifier in conjunction with a bit mask that defines the various roles a server plays.
A good choice is the bit mask approach because you can easily implement the script with numerous scripting languages. Using the bit mask approach involves creating an input file of servers and writing a script. In the following example, I'll show you how to prepare a table of server-type identifiers, create the Servers.txt input file, and use VBScript to write the SrvrRole.vbs script.
Preparing the Table
Before you create the Servers.txt input file, you need to prepare a table of server types, bits, and bit values. Table 1 shows the server types and their associated bits and server-type values for this example. In the first column, you identify the types of servers in your network. The server types can be in any order. In the second column, you assign a unique bit to identify each server type. In the last column, you assign a bit value to that server type. The bit values are the power function of 2, so that bit 1 is 20, bit 2 is 21, bit 3 is 22, and so on.
Next, list the server names in your network and determine what services each server provides. For example, a server might be a Primary Domain Controller (PDC), file server, and print server. Then, using the bits and server-type values in Table 1, calculate an overall value, or services value, for each server. Think of bits as on/off switches. If the server is providing the associated service, the bit is on (represented by a binary value of 1); otherwise, the bit is off (represented by a binary value of 0).
To calculate the services value, sum the server-type values of all the bits that are on. For example, if a server is a PDC, file server, and print server, the services value is 81 (1 + 16 + 64). If a server is a member server, FTP server, Internet Information Server (IIS) system, and SQL Server system, the services value is 5156 (4 + 32 + 1024 + 4096).