Determine if <computername> is domain member

M

Matt Hickman

I have a generated list of computernames and I want to determine, from
the command line, if those individual computers are members of the
domain or not. Is there a way to do this?

"netdom query /domain:<domainname> workstation" will give me a list of
workstations, but that gives me more than I want and takes an enormous
amount of time to complete.

Any ideas?

Thanks,
 
M

Michael Bednarek

I have a generated list of computernames and I want to determine, from
the command line, if those individual computers are members of the
domain or not. Is there a way to do this?

"netdom query /domain:<domainname> workstation" will give me a list of
workstations, but that gives me more than I want and takes an enormous
amount of time to complete.

netdom also seems incredibly slow. Have you tried:
dsquery computer -name workstation
It will return the distinguished name if workstation exists, and nothing
if it doesn't.

To get a list of computer accounts, much faster than netdom:
dsquery computer
and to display only the account (computer) name:
dsquery computer -o rdn
or
dsquery computer -o samid

Details at
<http://technet2.microsoft.com/Windo...43fd-4985-b429-cd53d3046f011033.mspx?mfr=true>.
 
J

Jerold Schulman

I have a generated list of computernames and I want to determine, from
the command line, if those individual computers are members of the
domain or not. Is there a way to do this?

"netdom query /domain:<domainname> workstation" will give me a list of
workstations, but that gives me more than I want and takes an enormous
amount of time to complete.

Any ideas?

Thanks,

In addition to dsquery, you can use ADFIND.EXE from tip 5898 » Freeware ADFind.
in the 'Tips & Tricks' at http://www.jsifaq.com

In the following isdom.bat file, "c:\zipnew\zcomp.txt" contains a list of computer names.

The output might look like:
"JSI009","Y"
"JSI007","Y"
"JSI003","N"
"JSI001","Y"


@echo off
setlocal ENABLEDELAYEDEXPANSION
for /f "Tokens=*" %%a in ('type "c:\zipnew\zcomp.txt"') do (
set DOM=N
for /f "Tokens=*" %%c in ('adfind -default -dsq -f "&(objectcategory=computer)(Name=%%a)"') do (
set DOM=Y
)
@echo "%%a","!DOM!"
)
endlocal

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top