Solved

How can we  export to a file all computers in NT4 domain?

Posted on 2011-02-17
5
402 Views
Last Modified: 2012-05-11
How can we  export to a file all computers in NT4 domain?
0
Comment
Question by:SAM2009
5 Comments
 
LVL 5

Assisted Solution

by:rdhoore108
rdhoore108 earned 50 total points
ID: 34920130
NETDOM.EXE should be able to do that, it is in the NT 4 Server Resource Kit supplement.
0
 
LVL 5

Expert Comment

by:rdhoore108
ID: 34920156
0
 
LVL 84

Assisted Solution

by:oBdA
oBdA earned 50 total points
ID: 34920805
Here's a batch script that should do the trick; should be running on any machine in the domain:
@echo off
setlocal
:: *** The number of the first useless lines of the 'net group "domain users" /domain' command output:
set NetFirst=4
:: *** The last line of the 'net group "domain users" /domain' command output:
set NetLast=The command completed successfully
:: *** In an NT4 domain, the domain computers are in the Domain Users group; 
:: *** in an AD domain, they're in the "Domain Computers" group:
set MachineGroup=Domain Computers
if "%UserDNSDomain%"=="" set MachineGroup=Domain Users

echo Computeraccounts in %Userdomain%:
for /f "skip=%NetFirst% delims=" %%a in ('net group "%MachineGroup%" /domain') do (
 set Line=%%a
 call :process
)
goto :eof

:process
:: *** Get the account names, configured in three columns:
set Account1=%Line:~0,25%
set Account2=%Line:~25,25%
set Account3=%Line:~50,25%
:: *** Avoid processing the "The command completed successfully" line
if /i "%Account1%"=="%NetLast:~0,25%" goto :eof
:: *** Remove spaces
if not "%Account1%"=="" set Account1=%Account1: =%
if not "%Account2%"=="" set Account2=%Account2: =%
if not "%Account3%"=="" set Account3=%Account3: =%
:: *** Write all accounts containing a "$":
if "%Account1%"=="" goto :eof
if not "%Account1%"=="%Account1:$=%" echo %Account1%
if "%Account2%"=="" goto :eof
if not "%Account2%"=="%Account2:$=%" echo %Account2%
if "%Account3%"=="" goto :eof
if not "%Account3%"=="%Account3:$=%" echo %Account3%
goto :eof

Open in new window

0
 
LVL 13

Accepted Solution

by:
Daz_1234 earned 400 total points
ID: 34924566
The script below will simply write the computer name of all computers in the domain to file C:\All_Domain_Computers.txt.

Daz.

'# Lists all computers in the Domain

Set fso = CreateObject("Scripting.FileSystemObject")
strDomain = "YOUR-DOMAIN"
strOutputFile = "C:\All_Domain_Computers.txt"
Set ts = fso.OpenTextFile(strOutputFile, 2, True)  '# Overwrite and create if not exist

Set oDomain = GetObject("WinNT://" & strDomain)
oDomain.filter = Array("Computer")
For Each oComputer In oDomain
    ts.WriteLine oComputer.Name
Next
ts.Close

MsgBox "Done!"

Open in new window

0
 
LVL 1

Author Closing Comment

by:SAM2009
ID: 34929143
Thnak you very much for all your suggestions. I very appreciate it!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question