You are previewing Windows® Command-Line Administrators Pocket Consultant, Second Edition.
O'Reilly logo
Windows® Command-Line Administrators Pocket Consultant, Second Edition

Book Description

Now updated for Windows Server 2008 and Windows Vista, this practical, pocket-sized reference delivers ready answers for using Windows command-line tools to manage multiple clients and servers. It s packed with hundreds of examples that show you how to run, use, schedule, and script Windows commands, support tools, and Resource Kit tools without touching the GUI. Written by a well-known author of more than two dozen computer books and featuring easy-to-read tables, lists, and step-by step instructions this POCKET CONSULTANT delivers fast, accurate information on the spot.

Key Book Benefits:

Provides fast facts and immediate reference for using Windows command-line tools to manage multiple clients and servers, perform bulk operations, and get more done in less time Delivers hundreds of examples of how to use Windows commands, support tools, Resource Kit tools, and batch scripts Features concise tables, easy-to-scan lists, and step-by-step instructions for immediate answers wherever you need them at your desk or in the field Updated for Windows Vista and Windows Server 2008

Table of Contents

  1. Windows® Command-Line Administrator's Pocket Consultant, Second Edition
  2. Acknowledgments
  3. Introduction
    1. Who Is This Book For?
    2. How Is This Book Organized?
    3. Conventions Used in This Book
    4. Support
  4. I. Windows Command-Line Fundamentals
    1. 1. Overview of the Windows Command Line
      1. Command Line Essentials
        1. Understanding the Windows Command Shell
        2. Understanding the MS-DOS Command Shell
        3. Understanding Windows PowerShell
        4. Configuring Command-Line Properties
        5. Working with the Command History
      2. Making Supplemental Components Available
        1. Using the Microsoft Remote Server Administration Tools for Windows Vista
        2. Registering the Remote Server Administration Tools Package
        3. Configuring and Selecting Remote Server Administration Tools
        4. Removing the Remote Server Administration Tools
        5. Removing the Remote Server Administration Tools Package
    2. 2. Getting the Most from the Command Line
      1. Managing Command Shell Startup
      2. Working with the Command Path
        1. Managing the Command Path
        2. Managing File Extensions and File Associations
      3. Redirecting Standard Input, Output, and Error
        1. Redirecting Standard Output to Other Commands
        2. Redirecting I/O to and from Files
        3. Redirecting Standard Error
      4. Chaining and Grouping Commands
        1. Using Chains of Commands
        2. Grouping Command Sequences
    3. 3. Command-Line Scripting Essentials
      1. Creating Command-Line Scripts
      2. Common Statements and Commands for Scripts
        1. Clearing the Command-Shell Window
        2. Adding Comments to Scripts
        3. Managing Text Display and Command Echoing
        4. Fine-Tuning Command Echo with @
        5. Setting the Console Window Title and Colors
      3. Passing Arguments to Scripts
      4. Getting Acquainted with Variables
      5. Using Variables in Scripts
        1. Naming Variables
        2. Setting Variable Values
        3. Substituting Variable Values
        4. Localizing Variable Scope
      6. Using Mathematical Expressions
        1. Working with Arithmetic and Assignment Operators
        2. Understanding Operator Precedence
        3. Simulating Exponents
      7. Command-Line Selection Statements
        1. Using If
        2. Using If Not
        3. Using If Defined and If Not Defined
        4. Nesting Ifs
        5. Making Comparisons in If Statements
      8. Command Line Iteration Statements
        1. Iteration Essentials
        2. Stepping Through a Series of Values
        3. Iterating Through Groups of Files
        4. Iterating Through Directories
        5. Parsing File Content and Output
      9. Creating Subroutines and Procedures
        1. Using Subroutines
        2. Using Procedures
  5. II. Windows Systems Administration Using the Command Line
    1. 4. Deploying Windows Servers
      1. Managing Server Configurations
      2. Working with Roles, Role Services, and Features
      3. Managing Roles, Role Services, and Features
        1. ServerManagerCmd Essentials
        2. Querying Installed Roles, Role Services, and Features
        3. Installing Roles, Role Services, and Features
        4. Removing Roles, Role Services, and Features
    2. 5. Managing Windows Systems
      1. Examining System Information
      2. Working with the Registry
        1. Understanding Registry Keys and Values
        2. Querying Registry Values
        3. Comparing Registry Keys
        4. Saving and Restoring Registry Keys
        5. Adding Registry Keys
        6. Copying Registry Keys
        7. Deleting Registry Keys
        8. Exporting and Importing Registry Keys
        9. Loading and Unloading Registry Keys
      3. Managing System Services
        1. Viewing Configured Services
        2. Starting, Stopping, and Pausing Services
        3. Configuring Service Startup
        4. Configuring Service Logon
        5. Configuring Service Recovery
      4. Restarting and Shutting Down Systems from the Command Line
        1. Managing Restart and Shutdown of Local Systems
        2. Managing Restart and Shutdown of Remote Systems
        3. Adding Shutdown or Restart Reasons and Comments
    3. 6. Event Logging, Tracking, and Monitoring.
      1. Windows Event Logging
      2. Viewing and Filtering Event Logs
        1. Viewing Events
        2. Filtering Events
      3. Writing Custom Events to the Event Logs
      4. Creating and Using Saved Queries
      5. Monitoring Performance: The Essentials
        1. Understanding Performance Monitoring at the Command Line
        2. Tracking Performance Data
    4. 7. Monitoring Processes and Maintaining Performance
      1. Managing Applications, Processes, and Performance
        1. Understanding System and User Processes
        2. Examining Running Processes
          1. Obtaining Detailed Information on Processes
          2. Viewing the Relationship Between Running Processes and Services
          3. Viewing Lists of DLLs Being Used by Processes
          4. Filtering Task List Output
        3. Monitoring System Resource Usage and Processes
        4. Stopping Processes
      2. Detecting and Resolving Performance Issues Through Monitoring
        1. Monitoring Memory Paging and Paging to Disk
        2. Monitoring Memory Usage and the Working Memory Set for Individual Processes
        3. Resolving Performance Bottlenecks
    5. 8. Managing Event and Performance Logging
      1. Managing the Event Logs
        1. Getting Started with Wevtutil
        2. Listing Available Logs and Registered Publishers
        3. Viewing and Changing Log Configuration
        4. Exporting and Manipulating Event Logs
        5. Clearing Event Logs
      2. Centralizing Event Logging Across the Enterprise
        1. Configuring Event Forwarding and Collection
        2. Creating Subscriptions
        3. Managing Subscriptions
      3. Performance Logging
        1. Getting Started with Data Collector Sets
        2. Working with Data Collector Sets
        3. Collecting Performance Counter Data
        4. Configuring Performance Counter Alerts
        5. Viewing Data Collector Reports
    6. 9. Scheduling Tasks to Run Automatically
      1. Scheduling Tasks on Local and Remote Systems
        1. Introducing Task Scheduling
        2. Monitoring Scheduled Tasks
      2. Scheduling Tasks with Task Scheduler
        1. Creating Basic Tasks
        2. Creating Advanced Tasks
        3. Managing Task Properties
        4. Enabling and Disabling Tasks
        5. Copying Tasks to Other Computers
        6. Running Tasks Immediately
        7. Removing Unwanted Tasks
      3. Scheduling Tasks with Schtasks
        1. Creating Scheduled Tasks with Schtasks /Create
        2. Creating Scheduled Tasks Triggered by Windows Events
        3. Changing Scheduled Tasks with Schtasks /Change
        4. Querying for Configured Tasks with Schtasks /Query
        5. Creating Tasks Using XML Configuration Files
        6. Running Tasks Immediately with Schtasks /Run
        7. Stopping Running Tasks with Schtasks /End
        8. Deleting Tasks with Schtasks /Delete
  6. III. Windows File System and Disk Administration Using the Command Line
    1. 10. Configuring and Maintaining Disks
      1. Getting Started with DiskPart
        1. DiskPart Basics
        2. DiskPart: An Example
        3. Understanding Focus and What It Means
        4. DiskPart Commands and Scripts
        5. DiskPart: A Script Example
      2. Installing and Managing Hard Disk Drives
        1. Installing and Checking for a New Drive
        2. Checking Drive Status and Configuration
        3. Changing Drive Partition Styles
          1. MBR and GPT Partition Styles
          2. Converting Partition Table Styles
      3. Working with Basic and Dynamic Disks
        1. Understanding Basic and Dynamic Disks
        2. Setting the Active Partition
        3. Changing the Disk Type: Basic to Dynamic or Vice Versa
          1. Converting a Basic Disk
          2. Converting a Dynamic Disk
      4. Maintaining Disks
        1. Obtaining Disk Information and Managing File Systems with FSUtil
          1. FSUtil: An Overview
          2. Using FSUtil
        2. Checking Disks for Errors and Bad Sectors
          1. Analyzing a Disk Without Repairing It
        3. Fixing Disk Errors
        4. Controlling Auto Check on Startup
          1. Determining Auto Check Status
          2. Configuring Auto Check Parameters
      5. Defragmenting Disks
        1. Understanding and Using Defrag
          1. Understanding and Using Defrag
          2. Performing Defrag Analysis Only
    2. 11. Partitioning Basic Disks
      1. Obtaining Partition Information
      2. Creating Partitions
        1. Creating Partitions for MBR Disks
          1. Creating Primary Partitions
          2. Creating Extended Partitions with Logical Drives
        2. Creating Partitions for GPT Disks
          1. Creating EFI System Partitions
          2. Creating Microsoft Reserved Partitions
          3. Creating Primary Partitions
          4. Creating LDM Metadata and LDM Data Partitions
      3. Managing Drive Letters and Mount Points
        1. Assigning Drive Letters or Mount Points
        2. Changing Drive Letters or Mount Points
        3. Removing Drive Letters or Mount Points
      4. Formatting Partitions
        1. Using FORMAT
        2. Using FILESYSTEMS
        3. Formatting: An Example
      5. Managing Partitions
        1. Converting a Partition or Volume to NTFS
          1. Conversion: Preliminary Checks
          2. Handling Basic Conversions
          3. Using the CvtArea Parameter
        2. Changing or Deleting the Volume Label
        3. Shrinking Partitions or Volumes
        4. Extending Partitions or Volumes
        5. Deleting Partitions
    3. 12. Managing Volumes and RAID on Dynamic Disks
      1. Obtaining Volume Information and Status
      2. Creating and Managing Simple Volumes
        1. Creating Simple Volumes
        2. Extending Simple Volumes
        3. Bringing Dynamic Disks Online
        4. Deleting Volumes
      3. Providing Fault Tolerance with RAID on Dynamic Disks
        1. Implementing RAID-0: Disk Striping
          1. Using RAID-0
          2. Configuring the Stripe Set
        2. Implementing RAID-1: Disk Mirroring and Duplexing
          1. Using RAID-1
          2. Configuring Mirroring or Duplexing
        3. Implementing RAID-5: Disk Striping with Parity
          1. Using RAID-5
          2. Configuring Disk Striping with Parity
      4. Managing RAID and Recovering from Failure
        1. Breaking a Mirrored Set
        2. Resynchronizing and Repairing a Mirrored Set
        3. Repairing a RAID-0 Striped Set Without Parity
        4. Regenerating a RAID-5 Striped Set with Parity
  7. IV. Windows Active Directory Administration Using the Command Line
    1. 13. Core Active Directory Services Administration
      1. Controlling Active Directory from the Command Line
        1. Understanding Domains, Containers, and Objects
        2. Understanding Logical and Physical Structures in Active Directory
        3. Understanding Distinguished Names
        4. Getting Started with the Active Directory Command-Line Tools
      2. Making Directory Queries Using the DSQUERY Command
        1. DSQUERY Subcommands and Syntax
        2. Searching Using Names, Descriptions, and SAM Account Names
        3. Setting Logon and Run As Permissions for Searches
        4. Setting the Start Node, Search Scope, and Object Limit
        5. Setting the Output Format for Names
        6. Using DSQUERY with Other Active Directory Command-Line Tools
      3. Searching for Problem User and Computer Accounts
      4. Renaming and Moving Objects
      5. Removing Objects from Active Directory
    2. 14. Managing Computer Accounts and Domain Controllers
      1. Overview of Managing Computer Accounts from the Command Line
      2. Creating Computer Accounts in Active Directory Domains
        1. Creating a Computer Account
        2. Customizing Computer Account Attributes and Group Memberships
      3. Managing Computer Account Properties
        1. Viewing and Finding Computer Accounts
        2. Setting or Changing a Computer's Location or Description Attribute
        3. Disabling and Enabling Computer Accounts
        4. Resetting Locked Computer Accounts
        5. Joining Computer Accounts to a Domain
        6. Renaming Computers and Computer Accounts
        7. Moving Computer Accounts
        8. Deleting Computer Accounts
      4. Working with Domain Controllers
        1. Installing and Demoting Domain Controllers
        2. Finding Domain Controllers in Active Directory
      5. Designating Global Catalog Servers
        1. Finding Global Catalog Servers
        2. Adding or Removing a Global Catalog
        3. Checking Caching Settings and Global Catalog Preferences
      6. Designating Operations Masters
        1. Finding Operations Masters
        2. Configuring Operations Master Roles Using the Command Line
      7. Finding Read-Only Domain Controllers
    3. 15. Managing Active Directory Users and Groups
      1. Overview of Managing User Accounts from the Command Line
      2. Adding User Accounts
        1. Creating Domain User Accounts
        2. Customizing Domain User Account Attributes and Group Memberships
        3. Creating Local User Accounts
      3. Managing User Accounts
        1. Viewing and Finding User Accounts
        2. Determining Group Membership for Individual User Accounts
        3. Setting or Changing User Account Attributes
        4. Disabling and Enabling User Accounts
        5. Resetting Expired User Accounts
        6. Controlling and Resetting User Passwords
        7. Moving User Accounts
        8. Renaming User Accounts
        9. Deleting User Accounts
      4. Overview of Managing Group Accounts from the Command Line
      5. Adding Group Accounts
        1. Creating Security and Distribution Groups
        2. Creating a Local Group and Assigning Members
      6. Managing Group Accounts
        1. Viewing and Finding Group Accounts
        2. Determining Group Membership
        3. Changing Group Type or Scope
        4. Adding, Removing, or Replacing Group Members
          1. Adding Members to a Group
          2. Removing Members from a Group
          3. Replacing All Members in a Group
        5. Moving Group Accounts
        6. Renaming Group Accounts
        7. Deleting Group Accounts
  8. V. Windows Network Administration Using the Command Line
    1. 16. Administering Network Printers and Print Services
      1. Obtaining Support and Troubleshooting Information for Printers
        1. Working with Printers at the Command Line
        2. Tracking Print Drivers and Printer Information
        3. Getting Detailed Print Statistics for Capacity Planning and Troubleshooting
      2. Managing Printers
        1. Installing Physically Attached Print Devices
        2. Installing Network-Attached Print Devices
        3. Listing Printers Configured on a Computer
        4. Viewing and Setting the Default Printer
        5. Renaming Printers
        6. Deleting Printers
      3. Managing TCP/IP Ports for Network-Attached Printers
        1. Creating and Changing TCP/IP Ports for Printers
        2. Listing Information About TCP/IP Ports Used by Printers
        3. Deleting TCP/IP Ports Used by Printers
      4. Configuring Printer Properties
        1. Adding Comments and Location Information
        2. Sharing Printers
        3. Publishing Printers in Active Directory
        4. Setting a Separator Page and Changing Print Device Mode
        5. Scheduling and Prioritizing Print Jobs
        6. Configuring Spooling and Other Advanced Printer Options
      5. Solving Spooling Problems
        1. Checking the Print Spooler Service
        2. Fixing a Corrupted Spooler
      6. Managing Print Queues and Individual Print Jobs
        1. Viewing Jobs in the Queue
        2. Pausing the Printer and Resuming Printing
        3. Emptying the Print Queue
        4. Pausing, Resuming, and Restarting Individual Document Printing
        5. Removing a Document and Canceling a Print Job
      7. Backing Up and Restoring Print Server Configurations
        1. Backing Up Print Server Configurations
        2. Restoring Print Server Configurations
        3. Migrating Printers and Print Queues
    2. 17. Configuring, Maintaining, and Troubleshooting TCP/IP Networking
      1. Using the Network Services Shell
        1. Working with Netsh Contexts
        2. Working with Remote Computers
        3. Working with Script Files
      2. Managing TCP/IP Settings
        1. Configuring IPv4
          1. Setting a Static IPv4 Address
          2. Setting a Dynamic IPv4 Address
          3. Adding IPv4 Addresses and Gateways
          4. Setting DNS Servers to Use for IPv4
          5. Specifying Additional DNS Servers to Use
          6. Setting WINS Servers to Use
          7. Specifying Additional WINS Servers to Use
          8. Deleting IPv4 Address Resolution Protocol Cache
          9. Deleting TCP/IPv4 Settings
        2. Configuring IPv6
          1. Setting IPv6 Addresses
          2. Setting DNS Servers to Use for IPv6
          3. Deleting TCP/IPv6 Settings
      3. Supporting TCP/IP Networking
        1. Obtaining and Saving the TCP/IP Configuration
        2. Examining IP Address and Interface Configurations
        3. Working with TCP Internet Control and Error Messages
        4. Examining Fragmentation, Reassembly, and Error Details
        5. Examining Current TCP and UDP Connections
          1. Working with TCP
          2. Working with UDP
      4. Troubleshooting TCP/IP Networking
        1. Viewing Diagnostic Information
        2. Diagnosing General Computer Configuration Issues
          1. Diagnosing IP, DNS, and WINS Configuration Issues
          2. Trace the route to 192.168.1.100:
          3. Try to estalish a connection to Mailsever23 by its host name:
          4. Trace the route to Mailserver23.cpandl.com and provide packet loss information:
  9. A. Essential Command-Line Tools Reference
    1. ARP
    2. ASSOC
    3. ATTRIB
    4. BCDEdit
    5. CACLS
    6. Call
    7. CD
    8. CHDIR
    9. CHKDSK
    10. CHKNTFS
    11. Choice
    12. Cipher
    13. Clip
    14. CLS
    15. CMD
    16. CMDKey
    17. Color
    18. Comp
    19. Compact
    20. Convert
    21. Copy
    22. Date
    23. DCDIAG
    24. DCGPOFIX
    25. DEFRAG
    26. DEL
    27. DIR
    28. Diskcomp
    29. Diskcopy
    30. Diskpart
    31. DOSKey
    32. DriverQuery
    33. DSADD Computer
    34. DSADD Group
    35. DSADD User
    36. DSGET Computer
    37. DSGET Group
    38. DSGET Server
    39. DSGET User
    40. DSMGMT
    41. DSMOD Computer
    42. DSMOD Group
    43. DSMOD Server
    44. DSMOD User
    45. DSMOVE
    46. DSQUERY Computer
    47. DSQUERY Contact
    48. DSQUERY Group
    49. DSQUERY Partition
    50. DSQUERY Quota
    51. DSQUERY Server
    52. DSQUERY Site
    53. DSQUERY User
    54. DSQUERY *
    55. DSRM
    56. Echo
    57. Endlocal
    58. Erase
    59. ESENTUTL
    60. EventCreate
    61. Exit
    62. Expand
    63. FC
    64. Find
    65. FindStr
    66. FOR
    67. Forfiles
    68. Format
    69. FTP
    70. FTYPE
    71. GET-Eventlog
    72. GET-Process
    73. GET-Service
    74. GETMAC
    75. GOTO
    76. GPUPDATE
    77. HOSTNAME
    78. ICACLS
    79. IF
    80. IPCONFIG
    81. LABEL
    82. MD
    83. MKDIR
    84. MORE
    85. MOUNTVOL
    86. Move
    87. NBTSTAT
    88. NET Accounts
    89. NET Computer
    90. NET Config Server
    91. NET Config Workstation
    92. NET Continue
    93. NET File
    94. NET Group
    95. NET Localgroup
    96. NET Pause
    97. NET Print
    98. NET Session
    99. NET Share
    100. NET Start
    101. NET Statistics
    102. NET Stop
    103. NET Time
    104. NET Use
    105. NET User
    106. NET View
    107. NETDOM Add
    108. NETDOM Computername
    109. NETDOM Join
    110. NETDOM Move
    111. NETDOM MOVENT4BDC
    112. NETDOM Query
    113. NETDOM Remove
    114. NETDOM Renamecomputer
    115. NETDOM Reset
    116. NETDOM ResetPwd
    117. NETDOM Trust
    118. NETDOM Verify
    119. NETSH
    120. NETSTAT
    121. NSLOOKUP
    122. PATH
    123. PATHPING
    124. PAUSE
    125. PING
    126. POPD
    127. Print
    128. Prompt
    129. PUSHD
    130. RD
    131. Recover
    132. REG Add
    133. REG Compare
    134. REG Copy
    135. REG Delete
    136. REG Query
    137. REG Restore
    138. REG Save
    139. REGSVR32
    140. REM
    141. REN
    142. RMDIR
    143. Route
    144. Runas
    145. SC Config
    146. SC Continue
    147. SC Failure
    148. SC Pause
    149. SC QC
    150. SC QFAILURE
    151. SC Query
    152. SC Start
    153. SC Stop
    154. Schtasks /Change
    155. Schtasks /Create
    156. Schtasks /Delete
    157. Schtasks /End
    158. Schtasks /Query
    159. Schtasks /Run
    160. SERVERMANAGERCMD
    161. SET
    162. SET-Service
    163. SETLOCAL
    164. SFC
    165. SHIFT
    166. Shutdown
    167. Sort
    168. Start
    169. STOP-Process
    170. Stop-Service
    171. SUBST
    172. SYSTEMINFO
    173. TAKEOWN
    174. TASKKILL
    175. TASKLIST
    176. TIME
    177. TIMEOUT
    178. TITLE
    179. TRACERPT
    180. TRACERT
    181. TYPE
    182. TYPEPERF
    183. VER
    184. VERIFY
    185. VOL
    186. WAITFOR
    187. WBADMIN
    188. WHERE
    189. WHOAMI
  10. B. Quick Reference for Netsh
    1. Netsh
    2. Netsh Advfirewall
    3. Netsh Bridge
    4. Netsh Dhcp
    5. Netsh Dhcpclient
    6. Netsh Firewall
    7. Netsh Http
    8. Netsh Interface
    9. Netsh Ipsec
    10. Netsh Lan
    11. Netsh Nap
    12. Netsh Netio
    13. Netsh Nps
    14. Netsh P2p
    15. Netsh Ras
    16. Netsh Routing
    17. Netsh Rpc
    18. Netsh Winhttp
    19. Netsh Wins
    20. Netsh Winsock
    21. Netsh Wlan
  11. Index
  12. About the Author
  13. Copyright