Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Get all the users and groups who are in the Accept Messages only from

Hi,

I have some groups which is configured to Accept Messages only from..Is there a way to get all these groups with the members to a file.

Get all the users and groups who are in the Accept Messages only from

If required i can mention the group names too..All are oon the Root Domain.

Regards
Sharath
Avatar of harris_c
harris_c
Flag of Philippines image

Hi Sharath,
Check following script if this works for you!

:: SCRIPT START
@ECHO OFF
SETLOCAL EnableDelayedExpansion
IF EXIST GroupMembers.txt DEL /F /Q GroupMembers.txt
SET DrawLine=-----------------------------------------------------------
SET Qry=DSQuery * -Filter "(&(authOrig=*)(objectCategory=group))" -Attr sAMAccountName -Limit 0 -L
ECHO !DrawLine! >>GroupMembers.txt
FOR /F "delims=*" %%g IN ('%Qry%') DO (
      ECHO Querying: %%g
      ECHO Members Of: %%g >>GroupMembers.txt
      DSQuery * -Filter "(samAccountName=%%g)" -Attr authOrig -L >>GroupMembers.txt
      ECHO !DrawLine! >>GroupMembers.txt)
ECHO.&ECHO Script Complete. Check 'GroupMembers.txt' file.
ENDLOCAL
:: *** SCRIPT END ***
Avatar of bsharath

ASKER

Farhan

Where should i mention the input.
When i save the code and run it i just get a ------ nothing else.
Will it get all the users and groups who are in the Accept Messages only from box?
Farhan this works fine from the local Domain but from the root domain it does not fetch.Can you change it to even get details from the root domain
Replace following line
SET Qry=DSQuery * -Filter "(&(authOrig=*)(objectCategory=group))" -Attr sAMAccountName -Limit 0 -L
With
SET Qry=DSQuery * ForestRoot -Filter "(&(authOrig=*)(objectCategory=group))" -Attr sAMAccountName -Limit 0 -L
Farhan its getting me all the groups but not the members in it.
There are users who have been given access (Only from) They are not being listed.
Did you run the script with above changes?
Yes Farhan without the change i did not get anything.Now i am getting the names of the groups but not the members...
Can please post the contents of 'GroupMembers.txt' file
I get this...

-----------------------------------------------------------
Members Of: CHENNAI
-----------------------------------------------------------
Members Of: France
-----------------------------------------------------------
Members Of: Newyork
-----------------------------------------------------------
Members Of: Warrington
-----------------------------------------------------------
Apply following commands (one-by-one) and post the results.

Click Start -> Run -> Cmd.exe

DSQuery * -Filter "(samAccountName=CHENNAI)" -Attr authOrig -L
DSQuery * -Filter "(samAccountName=France)" -Attr authOrig -L
DSQuery * -Filter "(Name=Warrington)" -Attr authOrig -L
DSQuery * -Filter "(samAccountName=Newyork)" -Attr * -L
farhan

I dont get any results...

What about following:

DSQuery * ForestRoot -Filter "(samAccountName=Newyork)" -Attr * -L

DSQuery Group -Name Newyork
For this i get all the details...

DSQuery * ForestRoot -Filter "(samAccountName=Newyork)" -Attr * -L

Its a very big data so not pasting it here

DSQuery Group -Name Newyork
I dont get any results
ASKER CERTIFIED SOLUTION
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot farhan

Any help with the other Q's
Thanks for the points.
Can you please post the links here...