Compare members of two groups

B

Brian

Is there a way of comparing the members of two global
security in an AD environment? The sort of information I
am after is who is a member of Group A and Group B. Is
there something that can be done with VBScript?
 
P

Pegasus \(MVP\)

Brian said:
Is there a way of comparing the members of two global
security in an AD environment? The sort of information I
am after is who is a member of Group A and Group B. Is
there something that can be done with VBScript?

You could try this batch file:

@echo off

if "%2"=="" goto Error

pushd %temp%
call :Assemble %1
call :Assemble %2
call :Compare %1 %2
type Common.txt
popd

goto :eof
========================================
:Assemble
if exist %1.* del %1.*
net group %1 | more +6 | find /i /v "successfully" > %1.1
for /F "tokens=1-3" %%a in (%1.1) do (
echo %%a >> %1.2
if not "%%b"=="" echo %%b >> %1.2
if not "%%c"=="" echo %%c >> %1.2
)
goto :eof
========================================
:Compare
echo. > Common.txt
echo Users common to %1 and %2 >> Common.txt
echo ------------------------------ >> Common.txt
for /F %%a in (%1.2) do type %2.2 | find /i "%%a" >>common.txt
goto :eof
========================================
:Error
echo.
echo Usage: Group.bat GroupA GroupB
 
B

Brian

That's great thanks. However, can you think of a way of
doing this without net group, as this can only be executed
on a domain controller. I want to be able to run this from
any workstation.

Cheers
 
P

Pegasus \(MVP\)

Your assumption is incorrect. The command "net group"
can be executed on any workstation:

net group SomeGroupName /domain
 
B

Brian

-----Original Message-----
Your assumption is incorrect. The command "net group"
can be executed on any workstation:

net group SomeGroupName /domain
That's great, thanks!
 

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

Similar Threads


Top