Solved

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

Posted on 2011-02-17
5
403 Views
Last Modified: 2012-05-11
How can we  export to a file all computers in NT4 domain?
0
Comment
Question by:SAM2009
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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