O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Windows Server Hacks
By Mitch Tulloch
March 2004
More Info

How do these hacks stand up? Comment on a hack from the book by choosing the associated "Discuss" link below. You can also view the code from any of the hacks by clicking on the "Listing" or "Code" links. A number of hacks have been selected to be featured online in their entirety; you may view those hacks by clicking on the hack titles that are linked.

You can also download all the scripts and other files for this book here.

Jump to: General Administration  | Active Directory  | User Management  | Networking Services  | File and Print  | IIS  | Deployment  | Security  | Patch Management  | Backup and Recovery

General Administration

HACK
#1

Use Run As to Perform Administrative Tasks
Use Run As to protect your administrator workstation from Trojans and other nasties
[Discuss (1) | Link to this hack]

HACK
#2

Drag and Drop to the Run Menu
If you're tired of having to drop out to a command prompt and navigate through folders to run an executable that requires switches, try this
[Discuss (0) | Link to this hack]

HACK
#3

Find and Replace Registry Keys from a Command Line
Using the Regfind utility, you can easily search the Registry for a value, regardless of the key, and replace it
The Code
[Discuss (0) | Link to this hack]

HACK
#4

Automatically Log On After Booting
It's sometimes convenient to configure machines to log on automatically when booted. Here are three ways to do this
[Discuss (0) | Link to this hack]

HACK
#5

Wait for and Optionally Terminate a Process
If you've wondered how to write code that waits for a process to finish before terminating it, here's the answer
The Code
[Discuss (0) | Link to this hack]

HACK
#6

Shut Down a Remote Computer
Here's a nifty way to use a script to shut down remote machines

[Discuss (5) | Link to this hack]

HACK
#7

Rename Mapped Drives
Renaming drive mappings can be done in several ways, but automating the process is most efficient using a script
The Code
[Discuss (7) | Link to this hack]

HACK
#8

Execute a Command on Each Computer in a Domain
This handy script lets you easily run any command on a specified subset of computers in your domain
The Code
[Discuss (1) | Link to this hack]

HACK
#9

Add, Remove, or Retrieve Environment Variables
Environment variables can easily be added, removed, or retrieved using the script in this hack
The Code
[Discuss (0) | Link to this hack]

HACK
#10

Extend Group Policy
Group Policy is a powerful tool for managing Windows systems, but by configuring ADM files you can extend its capabilities even further
[Discuss (0) | Link to this hack]

HACK
#11

Disable EFS
While the Encrypted File System of Windows 2000/XP can be useful for protecting data, your best approach might actually be to disable it
[Discuss (0) | Link to this hack]

HACK
#12

Get Event Log Information
Need to check on the size and configuration settings of your event logs? Use this script instead of the GUI; it's faster!
The Code
[Discuss (0) | Link to this hack]

HACK
#13

Shortcut to Remote Assistance
Remote Assistance is a helpful feature for troubleshooting Windows XP systems, but it's a pain for ordinary users to use. This hack creates a helpful shortcut to this feature
[Discuss (4) | Link to this hack]

HACK
#14

Desktop Checker
Here's a useful script to quickly display the configuration of a remote system for troubleshooting or inventory purposes
The Code
[Discuss (0) | Link to this hack]

HACK
#15

Top Five Tools
Here's one IT professional's take on five third-party tools for Windows 2000 every system administrator should have
[Discuss (0) | Link to this hack]

HACK
#16

myITforum.com
One of the best resources around for administrators who deploy and manage Windows-based networks, myITforum.com is best described by its CEO and founder, Rod Trent
[Discuss (0) | Link to this hack]

Active Directory

HACK
#17

Retrieve the List of Old Domain Computer Accounts
Finding inactive computer accounts in Active Directory is a chore—unless, of course, you script it
The Code
[Discuss (2) | Link to this hack]

HACK
#18

Automate Creation of OU Structure
Here's a snappy method for creating a standard hierarchy of organizational units (OUs) for a domain
The Code
[Discuss (1) | Link to this hack]

HACK
#19

Modify All Objects in the OU
Use this script to quickly change specific properties of all objects within an organizational unit
The Code
[Discuss (0) | Link to this hack]

HACK
#20

Delegate Control of an OU to a User
Rather than use the Delegation of Control Wizard, use this script to delegate authority over an organizational unit (OU) to a particular user
The Code
[Discuss (1) | Link to this hack]

HACK
#21

Send OU Information in Active Directory to an HTML Page
Here's a terrific way to quickly display all the organizational units (OUs) in a domain
The Code
[Discuss (2) | Link to this hack]

HACK
#22

Display Active Directory Information
Here are five sample scripts that can be used to display information about computers, domains, sites, and trusts in Active Directory
[Discuss (1) | Link to this hack]

HACK
#23

Store and Display Contact Information in Active Directory
Using a script and an Access database, you can store detailed contact information in Active Directory and display it as an HTML page
The Code
[Discuss (4) | Link to this hack]

HACK
#24

Restore the Active Directory Icon in Windows XP
A useful feature in Windows 2000 that enables users to browse Active Directory is missing in Windows XP; here's how to get it back
[Discuss (0) | Link to this hack]

User Management

HACK
#25

Search for Domain Users
Programmatically search for a user in a mixed Windows NT/2000 environment
The Code
[Discuss (0) | Link to this hack]

HACK
#26

Manage User Accounts in Active Directory
Use these five handy scripts to easily manage domain user accounts
[Discuss (0) | Link to this hack]

HACK
#27

Get a List of Disabled Accounts
Here's a fast way to determine any disabled user accounts in your Active Directory forest
The Code
[Discuss (0) | Link to this hack]

HACK
#28

Get User Account Information
Need to find information about user accounts on a machine? Use this handy script to do it fast
The Code
[Discuss (1) | Link to this hack]

HACK
#29

Check for Passwords that Never Expire
Here's a handy script that makes it simple to find user accounts with nonexpiring passwords
The Code
[Discuss (2) | Link to this hack]

HACK
#30

Enumerate Group Membership to a CSV File
Export a list of which users are in which groups to a comma-separated file that is suitable for opening in your favorite spreadsheet or database application
The Code
[Discuss (4) | Link to this hack]

HACK
#31

Modify User Properties for All Users in a Particular OU
Changing the logon script for all users in an organizational unit (OU) is a chore if you're working from the GUI, so try this script instead
The Code
[Discuss (0) | Link to this hack]

HACK
#32

Check Group Membership and Map Drives in a Logon Script
Find out which group a user referenced within a logon script belongs to
The Code
[Discuss (0) | Link to this hack]

HACK
#33

Script Creation of a User's Home Directory and Permissions
Configuring home directories for users is a slow process using the GUI. Here's a script that does it faster
The Code
[Discuss (1) | Link to this hack]

HACK
#34

Prevent Ordinary Users from Creating Local Accounts
Here's a quick hack that will let you prevent users from creating new local user accounts on their desktop computers
[Discuss (0) | Link to this hack]

HACK
#35

Put a Logoff Icon on the Desktop
Here's a script that will enable users to safely reboot their machines when necessary
The Code
[Discuss (0) | Link to this hack]

Networking Services

HACK
#36

Manage Services on Remote Machines
Here are three handy scripts for managing network services that run on remote machines
[Discuss (0) | Link to this hack]

HACK
#37

Simplify DNS Aging and Scavenging
Understanding the mysteries of how DNS aging/scavenging works can save you time and effort troubleshooting DNS name-resolution problems
[Discuss (0) | Link to this hack]

HACK
#38

Troubleshoot DNS
Here are some tips, tools, and resources to help you troubleshoot DNS problems on Windows 2000/2003-based networks
[Discuss (0) | Link to this hack]

HACK
#39

Manually Recreate a Damaged WINS Database
A corrupt WINS database can spell a host of problems and must be repaired if your network is to function properly. This hack shows you how to recreate a damaged WINS database
[Discuss (0) | Link to this hack]

HACK
#40

Change WINS for All Enabled Adapters
Changing WINS settings on client machines can be a pain when you have to move your WINS servers. This hack makes it easier
The Code
[Discuss (1) | Link to this hack]

HACK
#41

Ensure DHCP Server Availability
Making sure a DHCP server is always available is critical if your network uses dynamic TCP/IP addressing
[Discuss (0) | Link to this hack]

HACK
#42

Change a Network Adapter's IP Info
Changing TCP/IP settings via the GUI is tedious at best. It's accomplished more easily with a little VB scripting magic
The Code
[Discuss (0) | Link to this hack]

HACK
#43

Change from Static IP to DHCP
Reconfiguring a network from static IP addressing to DHCP is a chore no system administrator wants to do, but now there's help
The Code
[Discuss (1) | Link to this hack]

HACK
#44

Release and Renew IP Addresses
Using this handy script, you can release and renew a dynamically assigned IP address with a click of the mouse—well, two clicks, actually
The Code
[Discuss (2) | Link to this hack]

HACK
#45

Use netsh to Change Configuration Settings
You can use the Windows 2000 Netshell (netsh) command to do some amazing things, including switching your machine between two different network configurations
[Discuss (0) | Link to this hack]

HACK
#46

Remove Orphaned Network Cards
Moving a network adapter card to a new PCI slot in Windows 2000/XP can sometimes cause unexpected results
[Discuss (0) | Link to this hack]

HACK
#47

Implement Windows 2000 Network Load Balancing
If you need network load balancing software on your network, why not try the NLB component that comes with Windows 2000 Advanced Server?
[Discuss (0) | Link to this hack]

File and Print

HACK
#48

Map Network Drives
This quick way to map a network drive can replace the traditional approach of using batch files
The Code
[Discuss (0) | Link to this hack]

HACK
#49

Determine Who Has A Particular File Open on the Network
Using the Hyena utility, quickly find out which user on your network has a particular file open
[Discuss (0) | Link to this hack]

HACK
#50

Display a Directory Tree
Using some simple coding, you can display a complete map of a directory structure from a command prompt
The Code
[Discuss (0) | Link to this hack]

HACK
#51

Automate Printer Management
Here are a couple nifty ways to manage printers from the command line instead of via the GUI
[Discuss (0) | Link to this hack]

HACK
#52

Set the Default Printer Based on Location
Using a combination of Group Policy and logon scripts, you can easily assign different default printers to different users
The Code
[Discuss (0) | Link to this hack]

HACK
#53

Add Printers Based on Name of Computer
Here's a logon script you can use to solve a complicated problem in printer management: performing a logon task based on the name of the computer being logged into
The Code
[Discuss (2) | Link to this hack]

IIS

HACK
#54

Back Up the Metabase
There's more than one reason for backing up the metabase, and there are different ways of doing it too
[Discuss (0) | Link to this hack]

HACK
#55

Restore the Metabase
While it's simple to restore the metabase from a backup, what if you have no backup or can't open the GUI? Use this hack
[Discuss (0) | Link to this hack]

HACK
#56

Map the Metabase
Here are some helpful maps to help you navigate the complexities of the metabase
[Discuss (0) | Link to this hack]

HACK
#57

Metabase Hacks
Here are 10 things you might want to change with IIS, but you can do them only by editing the metabase
[Discuss (0) | Link to this hack]

HACK
#58

Hide the Metabase
Protect the metabase on your critical web servers by hiding its name and location from attackers
[Discuss (0) | Link to this hack]

HACK
#59

IIS Administration Scripts
Here are some handy scripts that can be used to administer IIS from the command line
[Discuss (0) | Link to this hack]

HACK
#60

Run Other Web Servers
Here's how to run another web server, in addition to IIS, on the same machine without conflict over who gets port 80
[Discuss (0) | Link to this hack]

HACK
#61

IISFAQ
Here's a brief overview of IISFAQ, Chris Crowe's valuable web site that every IIS administrator should know about
[Discuss (0) | Link to this hack]

Deployment

HACK
#62

Get Started with RIS
Remote Installation Services (RIS) is a complex but powerful tool for deploying Windows images. Here's a guide to getting started with it
[Discuss (0) | Link to this hack]

HACK
#63

Customize RIS
Once you know the basics of setting up RIS, you can customize it for the needs of your own networking environment
[Discuss (0) | Link to this hack]

HACK
#64

Tune RIS
If you can't afford the resources to run a dedicated RIS server for your environment, you can use RIS on a dual-purpose server—as long as you tune it carefully
[Discuss (0) | Link to this hack]

HACK
#65

Customize SysPrep
Using SysPrep to deploy Windows can be a nightmare, unless you find a way to minimize the number of images you have to maintain
[Discuss (0) | Link to this hack]

HACK
#66

Remove Windows Components from the Command Line
Here's a handy utility you can use from the command line to remove Windows components and protected files
[Discuss (0) | Link to this hack]

HACK
#67

Unattended Installation of Windows Components
Here's a simple way you can add or remove system components when deploying Windows 2000 and later
[Discuss (5) | Link to this hack]

HACK
#68

Easily Create a Network Boot Disk
One of the headaches of deploying Windows is creating network boot disks. Here's a speedy solution
[Discuss (0) | Link to this hack]

Security

HACK
#69

Fundamentals of a Virus-Free Network
Here are some fundamentals you need to pay attention to if you want to keep your network free of viruses
[Discuss (0) | Link to this hack]

HACK
#70

Antivirus FAQ
Rod Trent of myITforum.com, shares his answers to some frequently asked questions on the subject of virus protection
[Discuss (0) | Link to this hack]

HACK
#71

Rename the Administrator and Guest Accounts
Renaming the default administrator and guest accounts is a simple but effective step to help secure your machines
[Discuss (0) | Link to this hack]

HACK
#72

Get a List of Local Administrators
Local administrators can do anything on their machines. Here's a quick way to determine who has this power
The Code
[Discuss (0) | Link to this hack]

HACK
#73

Find All Computers that Are Running a Service
Use this script to find rogue web servers, misconfigured clients, and other potentially insecure systems on your network
The Code
[Discuss (0) | Link to this hack]

HACK
#74

Grant Administrative Access to a Domain Controller
Here's a hack that will help you secure any domain controllers you have running at a remote site
[Discuss (8) | Link to this hack]

HACK
#75

Secure Backups
Protect critical business information by restricting who can back up and restore it
[Discuss (0) | Link to this hack]

HACK
#76

Find Computers with Automatic logon Enabled
Having automatic logon enabled on a computer can be a security risk. Here's a quick way to find out which machines on your network have automatic logon enabled
[Discuss (0) | Link to this hack]

HACK
#77

Security FAQ
Rod Trent, CEO of myITforum.com, shares his answers to common security questions
[Discuss (0) | Link to this hack]

HACK
#78

Microsoft Security Tools
Here's a quick guide to various tools from Microsoft to help secure your systems against attack
[Discuss (0) | Link to this hack]

Patch Management

HACK
#79

Best Practices for Patch Management
By understanding the different kinds of patches and following a simple regime, you can keep your critical systems free from known vulnerabilities
[Discuss (0) | Link to this hack]

HACK
#80

Beginners Guide to Enterprise Patch Management
Here's another take on managing the patch-management cycle effectively in a large enterprise environment, written by an expert on the subject
[Discuss (0) | Link to this hack]

HACK
#81

Patch-Management FAQ
Rod Trent of myITforum.com shares his answers to some frequently asked questions on the subject of patch management
[Discuss (0) | Link to this hack]

HACK
#82

Enumerate Installed Hotfixes
Here's a script you can use to list all hotfixes installed on a machine
The Code
[Discuss (0) | Link to this hack]

HACK
#83

Apply Patches in the Correct Order
Deploying patches properly can sometimes mean applying them in the right order, as this experience can testify
[Discuss (0) | Link to this hack]

HACK
#84

Windows Update FAQ
Rod Trent of myITforum.com shares his answers to some frequently asked questions regarding Windows Update
[Discuss (0) | Link to this hack]

HACK
#85

Obtain Updates via the Windows Update Catalog
Whether you use it to download patches or driver updates, the Windows Update Catalog can be your friend
[Discuss (0) | Link to this hack]

HACK
#86

Use Automatic Updates Effectively
Automatic Updates is an easy way to ensure that your Windows servers are properly patched against critical vulnerabilities, but there are some nuances to using it effectively
[Discuss (0) | Link to this hack]

HACK
#87

Use Group Policy to Configure Automatic Updates
Use Group Policy to simplify the configuration of Automatic Updates in an Active Directory environment
[Discuss (0) | Link to this hack]

HACK
#88

Automatic Updates FAQ
Rod Trent of myITforum.com shares his answers to some frequently asked questions about the Automatic Updates feature of Windows 2000/XP/2003
[Discuss (0) | Link to this hack]

HACK
#89

Software Update Services FAQ
Rod Trent of myITforum.com shares his answers to some frequently asked questions regarding Software Update Services (SUS)
[Discuss (0) | Link to this hack]

Backup and Recovery

HACK
#90

Collect Disaster Recovery Files
Use this handy script to gather emergency repair files and event logs from Windows 2000 servers on your network
The Code
[Discuss (0) | Link to this hack]

HACK
#91

Back Up Individual Files from the Command Line
You can't back up individual files using the ntbackup command, but there's a workaround
[Discuss (0) | Link to this hack]

HACK
#92

Back Up System State on Remote Machines
Here's a hack that let's you use the Backup utility to perform a network backup of System State information on remote computers
[Discuss (0) | Link to this hack]

HACK
#93

Back Up and Restore a Certificate Authority
Backing up your local Certificate Authority is essential, because it forms the foundation for public key cryptography (PKI) for your organization
[Discuss (0) | Link to this hack]

HACK
#94

Back Up EFS
Backing up EFS recovery keys is essential if you want to be able to recover encrypted documents after a disaster
[Discuss (0) | Link to this hack]

HACK
#95

Work with Shadow Copies
Shadow copies are a new feature of Windows Server 2003 that lets you save point-in-time copies of your files—an excellent complement (but not a replacement) for your regular backup plan
[Discuss (0) | Link to this hack]

HACK
#96

Back Up and Clear the Event Logs
Here's a nifty script you can use to back up and clear the Event logs on your servers
The Code
[Discuss (0) | Link to this hack]

HACK
#97

Back Up the DFS Namespace
If you've implemented the Distributed File System (DSF) on your network, you need to back up your DFS namespace regularly
[Discuss (0) | Link to this hack]

HACK
#98

Recover with Automated System Recovery
Automated System Recovery (ASR) is a new feature of Windows Server 2003 that makes recovering from a disaster a whole lot easier
[Discuss (12) | Link to this hack]

HACK
#99

Recovery Roadmap
When it comes to troubleshooting startup problems, finding the right tool for the job is the key
[Discuss (0) | Link to this hack]

HACK
#100

Data Recovery of Last Resort
When the hard drive crashes on your server and your tape backup turns out to be a dud, who you gonna call? Use this hack
[Discuss (1) | Link to this hack]


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.