Welcome to How to Cheat at Windows System Administration Using Command-Line Scripts. This book is designed to help you learn the power of Windows command shell. There was a time in the history of computers when there was no graphical user interface (GUI), and every small and big task was performed using the commands and batch files. With every new version of Windows, Microsoft is trying to ease administrators’ jobs by adding more and more layers of GUI or configuration wizards (dialog boxes). Although these “wizards” are interactive and make the administrator’s job easier, they are not always the most convenient and efficient way to accomplish the everyday administration tasks. These wizards are time-consuming and, at times, may seem a bit confusing. There is certainly a way to avoid these wizards and still accomplish a given task using the command-line utilities included with the operating system.
Consider a situation where you wish to add a user to the Active Directory using the Windows wizards or the GUI, assign him/her appropriate permissions to access certain resources, and restrict access to others. It would take roughly one hour to complete the job. By using command line the same task could be done in about half the time. That not only saves you time but also increases your productivity as an administrator.
Although the importance of Windows GUIs should not be underrated, the com¬mand-line tools have their own importance and utility when it comes to increasing efficiency, boosting effectiveness, and saving time. Command-line tools are both problem solvers as well as time-savers. Not many administrators explore the usefulness of these tools. The purpose of this book is to let administrators know how to utilize these command-line tools to complete everyday administrative jobs, solve recurring network problems, and improve their efficiency.
This book contains a total of 13 chapters, divided into five different parts. The first part deals with the basics of Windows command shell, batch files, and scheduled tasks. The second part of the book deals with basic Windows system administration, which consists of managing files and hard disks. The third part of the book covers system ser¬vices, event logs, performance, and printing services. In the fourth part of the book, we cover Active Directory services. The fifth part of the book deals with managing net¬working services in a Windows Server 2003 environment.
Your journey starts in Chapter 1 with the basics of the Windows command shell. You will learn how to access the command shell and how to customize its properties. You will learn that the command shell’s properties can be modified in several different ways to suit your needs. Installing the support tools included with the Windows Server 2003 setup CD Windows is also covered in this chapter. You will also learn how to access the Windows A-Z Command Reference available in the Help and Support Center.In Chapter 2 we explain how to work safely with the command line using a non-administrative account. While working with the command shell, you sometimes need to specify a path where commands or batch files are located.You will learn how to change or modify the command path by modifying the environment variable either from the command prompt or from the System Properties dialog box. This chapter also explains how to change command input and output from the standard keyboard and the command shell window, respectively, and how to handle errors generated by com¬mands. Moving ahead, we will discuss the concept of creating simple batch files. You will learn about commonly used commands in batch files and how to use each com¬mand inside a batch file.
In Chapter 3, we discuss the task scheduler service, the Scheduled Tasks GUI, and the schtasks command-line utility. If the task scheduler service is not running, you will not be able to schedule any script or application to run automatically. The Scheduled Tasks wizard is a perfect tool for scheduling tasks to run at predetermined schedules, but you can also use the schtasks utility to perform the same tasks. This utility replaces the older AT command, which is still supported in Windows XP and Windows Server 2003. You will learn to use different subcommands of the schtasks utility to create, change, delete, query, run, or end a task. schtasks is considered to be one of the most complex command sets in Windows.
In Chapter 4, we discuss some of the very common commands used to manage and maintain files, folders, and floppy disks. Having in-depth knowledge of these com¬mands, their syntax, and their use is a great help when you want to use them in batch files or scripts to simplify your administrative tasks. Traditional Copy, Xcopy, Move, and Del (Erase) commands are covered in this chapter, and examples of their usage are included. We continue with the discussion on the use of the Diskcopy command for duplicating disks and comparing disks using the Diskcomp command. Other commands related to file and folder management such as Tree, MD (Mkdir), and RD (Rmdir) are also covered in this chapter.
Chapter 5 covers maintenance of file systems and hard disks. The most notable utilities covered in this chapter include Fsutil, Chkdsk, and Defrag. The Fsutil utility is new to the Windows XP and Windows Server 2003 families of operating systems. Although you might have experience with older utilities such as Chkdsk and Defrag, you will need to have thorough knowledge of the operating systems to use the Fsutil command and its subcommands when creating scripts. We will also discuss Format, Convert, and Compact commands in this chapter.
Chapter 6 is dedicated to the Diskpart command-line utility used to manage hard disk partitions and volumes. This utility is different from other command-line utilities in that it runs in the Windows command shell as a text-based command interpreter. This utility consists of several commands that run only after the Diskpart interpreter has started.You can use this utility to perform simple disk-related tasks, such as creating and deleting partitions and volumes, and complex tasks, such as creating, maintaining,and managing fault-tolerant volumes. Because Diskpart works in a more enhanced mode than its counterpart, the Disk Management snap-in, it has more control over the selected disk, partition, or volume. Diskpart supports scripting, and you can create scripts to automate repeated disk-related administrative tasks. Diskpart error codes make it easy for you to handle command execution more precisely.
In Chapter 7, we explain some of the key issues with maintaining the Windows operating system, including services, drivers, and most importantly, the Windows Registry. We discuss the SC and Reg command-line utilities, which offer sets of several subcommands that are helpful in configuring and maintaining the Windows operating system. You will rarely need to edit the Windows Registry directly, either from the GUI or from the command line, but it is good to understand how you can query, add, delete, save, and restore Registry entries.
In Chapter 8, we discuss some command-line utilities for monitoring and man¬aging event logs, processes, and performance logs. Monitoring is an important aspect of system and network administration, and you cannot ignore it. The command-line utili¬ties related to managing Windows event logs covered in this chapter include Eventcreate, Eventtriggers, and Eventquery. You will learn how to view system services and applications using the TaskList command and how to terminate nonresponsive pro¬cesses using the TaskKill command. This chapter also includes some command-line utilities for monitoring and managing performance logs. These utilities include TypePerf for displaying performance data in the command shell window, Lodctr for registering new performance counters in the Windows Registry, and Relog for extracting and resampling stored performance data.
We move on to Chapter 9 to discuss the command-line utilities used to manage printers and print jobs. It is interesting to note that most of these commands have very simple, facile syntax.You will learn that you can use the Prnmngr command to install printers while the Prncnfg command is used to view and configure installed printers. Other commands discussed in this chapter include Prndrvr, Prnport, Prnqctl, and Prnjobs to manage printer drivers, create and configure TCP/IP ports, manage print queues, and manage print jobs, respectively.
In Chapter 10, we introduce you to the basic syntax of the Directory Services (DS) commands for managing Active Directory objects. You will learn that the object classes that you can use with DS commands include computers (desktops and member servers), contacts, users, groups, servers (domain controllers), OUs, sites, subnets, quotas, and directory partitions.You will learn how to use the DSQuery command with dif¬ferent types of objects to search for objects in Active Directory, the DSGet command to display properties of specified objects, and the DSAdd and DSRm commands to add objects to or remove objects from the directory database, respectively. We explain the usage of the DSMod command to modify certain properties of specified objects and the DSMove command to move objects from one container to another within the domain.In Chapter 11, we take our discussion of Directory Service commands to the next level. This chapter includes several examples that will help you understand how simple it is to use the DS commands that otherwise look so complex.
Chapter 12 covers the procedures for performing basic network troubleshooting tasks and discusses the use of standard network tools available with Windows com¬mand-line utilities. We discuss the utilization of the Net command and its associated subcommands. We then examine a number of other network diagnostic tools, such as Ping, IPConfig, Pathping, Finger, and ARP. We examine the use of more powerful utili¬ties, such as Netstat and NBTStat, and learn to interpret the results of these commands. We also cover the versatile DNS querying command-line tool, NSLookup, in this chapter. Finally, we look at how to communicate with remote UNIX computers and the services they use—services that are not commonly, if at all, found on Windows computers.
You finish your learning journey in Chapter 13 with the discussion of the NETSH commands. You learn how the NETSH commands can be used to view the settings and configure networking components in a Windows Server 2003 environ¬ment. NETSH runs as a separate command interpreter within the Windows command shell and has a bundle of subcommands associated with it. Although it is not possible to discuss each NETSH command or subcommand within the scope of this book, we try to explain the most commonly used commands in this chapter.
With Windows XP and Windows Server 2003, Microsoft made several changes to the command-line functionality. It added several new commands and made changes to the functionality of some other commands. But at the same time, several commands have been dropped from the list of supported commands. These are some of the com¬mands you had been using ever since the MS-DOS operating system was introduced. The appendix in this book discusses the MS-DOS commands not supported in 32-and 64-bit editions of Windows XP and Windows Server 2003.
This book is an effort to introduce you to the powerful command-line utilities available in Windows XP and Windows Server 2003 operating systems. You will learn how to write batch files once you get a strong understanding of these utilities. Although this is not a scripting book, writing scripts or batch files is the next step after you get a grip of the basics. Most of the experienced system administrators depend on preconfigured batch files or scripts to manage networking services. A search on the Web can be very helpful for you to find ready-made scripts. But you must try these freely available scripts on a test server before using them on any production server.
Working on this book has been a great experience for all of us. We do hope that the results of the efforts put in by the team of authors, technical editors, and the edito¬rial staff at Syngress Publishing will result in an informative, useful, and enjoyable expe¬rience for our readers. We are always open to your suggestions.
—Pawan Bhardwaj MCSE, MCT, Security+, Network+, A+
Read Comments To Download
1 comments:
http://rapidshare.com/files/88518959/How_To_Cheat_At_Windows_System_Administration_Using_Command_Line_Scripts.pdf
or
http://tinyurl.com/2hbmwn
Post a Comment