Batch File Adds/Removes Machine Accounts in Server Manager
ID: Q140387
|
The information in this article applies to:
-
Microsoft Windows NT Workstation versions 3.5, 3.51, 4.0
-
Microsoft Windows NT Server versions 3.5, 3.51, 4.0
SUMMARY
An Windows NT network administrator may have to add a large number of
Windows NT Workstations or Non-Domain Controller Servers to a domain's
Machine Account database, which is accessed and maintained by the Server
Manager user interface.
MORE INFORMATION
In situations where a network administrator is setting up a network with a
large number of new machine accounts, it may be advantageous to consider
using a simple batch file to add all of the new machine accounts.
It is possible to add machine accounts with a command line utility under
Windows NT called NET COMPUTER. Its syntax is:
NET COMPUTER \\computername [/ADD | /DELETE]
Using NET COMPUTER Command in a Simple Batch File
This example adds 5 new machine accounts to the domain:
echo ***** Are you sure you want to add these accounts? *******
echo *** If not, press CTRL-C to terminate this batch file ***
pause
net computer \\NT1 /ADD
net computer \\NT2 /ADD
net computer \\NT3 /ADD
net computer \\NT4 /ADD
net computer \\NT5 /ADD
cls
echo ******* Machine Accounts Added ********
pause
NOTE: The NET COMPUTER command listed in this article can only be used to
add Windows NT Workstation or Windows NT Server (Non-Domain Controller
role) machine accounts to the Server Manager's database. Also, this command
or batch files that use this command should only be run at the Primary
Domain Controller(PDC). Once the batch file is run the administrator can
then synchronize the account database with the rest of the domain's Backup
Domain Controller's (BDC's).
Using the FOR Batch File Command in Conjunction with NET COMPUTER
Another way to accomplish this is to use the FOR command. The batch file
command FOR lets your batch file repeat a command for a specific set of
files. In this case, for the specific machine names we want to add to the
Server Manager database:
echo ***** Are you sure you want to add these accounts? *******
echo *** If not, press CTRL-C to terminate this batch file ***
pause
FOR %%X IN (NT1 NT2 NT3 NT4 NT5) DO NET COMPUTER \\%%X /ADD
FOR %%X IN (NT6 NT7 NT8 NT9 NT10) DO NET COMPUTER \\%%X /ADD
cls
echo ******* Machine Accounts Added ********
pause
NOTE: Under Windows NT, the command line is limited to 256 characters.
NET COMPUTER Errors
- The NET COMPUTER command will return an error level message for each
machine name that is attempted.
- If the computer name already exists in the Server Manager database the
message: "The computer \\name already exists." is returned with a NET
HELPMSG #3782.
- If the command completed successfully, a message saying so appears.
Using NET COMPUTER to Delete Many Machine Accounts
You can also remove many accounts by using the "\DEL" switch instead of the
"\ADD" switch in the batch files shown above.
Additional query words:
prodnt
Keywords : kbsetup kbusage ntdomain nthowto NTSrvWkst
Version : 3.5 3.51 4.0
Platform : winnt
Issue type :
Last Reviewed: January 30, 1999