VBScript

G

Guest

Hi all

Have you a vbscript which list all grupos in AD and list which members are
into the groups?

Cheers
 
P

Pegasus \(MVP\)

Maycon said:
Hi all

Have you a vbscript which list all grupos in AD and list which members are
into the groups?

Cheers

You could do it with this batch file:

Line1 @echo off
Line2 if exist c:\Groups.txt del c:\Groups.txt
Line3 for /F "tokens=*" %%* in ('net group ^| find "*"') do call :Sub %%*
Line4 goto :eof
Line5
Line6 :sub
Line7 set name=%*
Line8 net group "%name:~1%" | find /i /v "comment" | find /i /v "members" |
find /i /v "--------------" | find /i /v "completed successfully" >>
c:\Groups.txt
Line9 notepad c:\Groups.txt
 
P

Pegasus \(MVP\)

Try some manual commands from a Command Prompt. The command

net groups

will show you all your groups. Is the list complete? If it is, what
group does it list that is missing in my batch file output?
 
G

Guest

When I look into AD I have 170 groups and via net command just 139
some groups called fil-xxxx do not appear.
 
P

Pegasus \(MVP\)

Sorry, don't know about that one. I was under the impression
that the command "net groups" lists each and every AD group.
Your report suggests otherwise. Perhaps the command

net help groups

will shed some light on this issue.
 
G

Guest

I believe because some are Domain Global and other Domain local. How can I
list all?
Cheers
 
P

Pegasus \(MVP\)

Try this:

Line1 @echo off
Line2 if exist c:\Groups.txt del c:\Groups.txt
Line3 for /F "tokens=*" %%* in ('net groups ^| find "*"') do call :Sub %%*
Line4 for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call
:Sub %%*
Line5 goto :eof
Line6
Line7 :sub
Line8 set name=%*
Line9 net group "%name:~1%" | find /i /v "comment" | find /i /v "members" |
find /i /v "--------------" | find /i /v "completed successfully" >>
c:\Groups.txt
Line10 notepad c:\Groups.txt
 
P

Pegasus \(MVP\)

Again you have to go back to basics:
net groups
net groups /domain
net localgroups
net help groups
 
G

Guest

Yeah, net localgroup works show some of them which wasn't in the first script.
But how can I include into Script?
 
P

Pegasus \(MVP\)

Line1 @echo off
Line2 if exist c:\Groups.txt del c:\Groups.txt
Line3 for /F "tokens=*" %%* in ('net localgroups ^| find "*"') do call :Sub
%%*
Line4 for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call
:Sub %%*
Line5 notepad c:\Groups.txt
Line6 goto :eof
Line7
Line8 :sub
Line9 set name=%*
Line10 net group "%name:~1%" | find /i /v "comment" | find /i /v "members" |
find /i /v "--------------" | find /i /v "completed successfully" >>
c:\Groups.txt
 
G

Guest

I have got message for net localgroup:

The system cannot find the batch label specified - Sub*Fil-Orgdata-Browser
Any ideia?

Thank you
 
P

Pegasus \(MVP\)

You made a mistake when reconstituting the broken up lines.
I cannot tell what mistake it is unless you attach your version
of the batch file to your post.
 
G

Guest

Okay, here it is:
@echo off
if exist c:\Groups.txt del c:\Groups.txt
for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call :Sub%%*
for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call :Sub %%*
goto :eof
:sub
set name=%*
net group "%name:~1%" | find /i /v "comment" | find /i /v "members" | find
/i /v "--------------" | find /i /v "completed successfully" >> c:\Groups.txt


Thanks
 
P

Pegasus \(MVP\)

Compare the two "call" statements:
call :Sub%%*
call :Sub %%*

The second one is correct. The first one lacks a space after "Sub".
 
P

Pegasus \(MVP\)

Furthermore, the "notepad" statement is in the wrong place.

Line1 @echo off
Line2 if exist c:\Groups.txt del c:\Groups.txt
Line3 for /F "tokens=*" %%* in ('net localgroups ^| find "*"') do call :Sub
%%*
Line4 for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call
:Sub %%*
Line5 notepad c:\Groups.txt
Line6 goto :eof
Line7
Line8 :sub
Line9 set name=%*
Line10 net group "%name:~1%" | find /i /v "comment" | find /i /v "members" |
find /i /v "--------------" | find /i /v "completed successfully" >>
c:\Groups.txt
 
G

Guest

I have change net group for netlocalgroup as well so It's working

Thanks you very much. :)
 
G

Guest

Hi mate
Any option to list user and give which group they have applied or in your
scripts
can I get as result something like that? Using comma.
E:\Group Shares\Vol1\, MWL\Administrator:(OI)(CI)F , MWL\Domain
Users:(OI)(CI), F, MWL\a-MayconR:(OI)(CI)F

cheers
 

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