VBScript

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

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

Cheers
 
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
 
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?
 
When I look into AD I have 170 groups and via net command just 139
some groups called fil-xxxx do not appear.
 
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.
 
I believe because some are Domain Global and other Domain local. How can I
list all?
Cheers
 
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
 
Again you have to go back to basics:
net groups
net groups /domain
net localgroups
net help groups
 
Yeah, net localgroup works show some of them which wasn't in the first script.
But how can I include into Script?
 
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
 
I have got message for net localgroup:

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

Thank you
 
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.
 
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
 
Compare the two "call" statements:
call :Sub%%*
call :Sub %%*

The second one is correct. The first one lacks a space after "Sub".
 
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
 
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
 
Back
Top