Thursday, May 19, 2011

Identify Domain Memebership

Here is the batch file script which you can used to find if a computer is member of a domain or in workgroup.

Script #1 – Using Systeminfo command

FOR /f %%i in (c:\computers.txt) do (

echo %%i >> c:\output.txt

systeminfo /s %%i | find "Domain" >> c:\output.txt)

Script #2 – By checking the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon/DefaultDomainName reg key

FOR /f %%i in (c:\computers.txt) do (

echo %%i >> c:\output.txt

reg query "\\%%i\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /V DefaultDomainName /s | find "DefaultDomainName" >> c:\output.txt)

If you want use the Script #2, make sure the  the remote registry service is running on the computer.  Also, my assumption is t if HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon/DefaultDomainName  is not present, this computer is part of a WORKGROUP.

I create this script based on a question posted on the TechNet forum

0 comments:

Post a Comment

Popular Posts

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More