bsharath
asked on
Get all groups from a particular OU
Hi,
I have some Groups on my root domain so need a way where i can specify the OU path so that i can get all groups from that OU.
REgards
Sharath
I have some Groups on my root domain so need a way where i can specify the OU path so that i can get all groups from that OU.
REgards
Sharath
* Following batch script will get all the members of groups that are specified in Groups.txt file.
* It will generate a file on C: drive root with name GroupMembers.txt having all members information.
* Copy and paste following script in notepad and save it with .BAT extension.
:: *** BATCH SCRIPT START ***
@Echo Off
SETLOCAL
IF NOT EXIST C:\groups.txt Goto ShowErr
FOR %%R IN (C:\groups.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\GroupMembers.txt DEL /F /Q C:\GroupMembers.txt
FOR /F "delims=#" %%g in (C:\groups.txt) Do (
Echo Retrieving members of group: %%g
Echo Retrieving members of group: %%g >>C:\GroupMembers.txt
DSQuery group -name "%%g*" | dsget group -members >>C:\GroupMembers.txt
Echo. >>C:\GroupMembers.txt
)
Goto EndScript
:ShowErr
Echo C:\groups.txt file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** BATCH SCRIPT END ***
Hope it helps.
* It will generate a file on C: drive root with name GroupMembers.txt having all members information.
* Copy and paste following script in notepad and save it with .BAT extension.
:: *** BATCH SCRIPT START ***
@Echo Off
SETLOCAL
IF NOT EXIST C:\groups.txt Goto ShowErr
FOR %%R IN (C:\groups.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\GroupMembers.txt DEL /F /Q C:\GroupMembers.txt
FOR /F "delims=#" %%g in (C:\groups.txt) Do (
Echo Retrieving members of group: %%g
Echo Retrieving members of group: %%g >>C:\GroupMembers.txt
DSQuery group -name "%%g*" | dsget group -members >>C:\GroupMembers.txt
Echo. >>C:\GroupMembers.txt
)
Goto EndScript
:ShowErr
Echo C:\groups.txt file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** BATCH SCRIPT END ***
Hope it helps.
Ohoh! Sorry I answered to the wrong question.
ASKER
Can you help me in this question..
https://www.experts-exchange.com/questions/22598016/Change-Computer-Description-for-all-machines.html
https://www.experts-exchange.com/questions/22598016/Change-Computer-Description-for-all-machines.html
ASKER
Any help....
The dsquery command above will "get all groups from that OU".
You need to be more specific if you requiore more help.
You need to be more specific if you requiore more help.
ASKER
Hi OBDA,
I have a primary and a secondary domain.
EX: Root is "All" and below it is "development".
When ever i run any query it fetches all the details from the development domain not the All domain.That's the reason i wanted a way to be specific .where we can mention the OU and DC.
REgards
Sharath
I have a primary and a secondary domain.
EX: Root is "All" and below it is "development".
When ever i run any query it fetches all the details from the development domain not the All domain.That's the reason i wanted a way to be specific .where we can mention the OU and DC.
REgards
Sharath
As in the example above; dsquery expects the node to start its search as argument:
dsquery group "dc=development,dc=all,dc= local"
or whatever.
You can specify the server or domain to query as well using the -s or -d switch; check the link above for details.
dsquery group "dc=development,dc=all,dc=
or whatever.
You can specify the server or domain to query as well using the -s or -d switch; check the link above for details.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
dsquery group "ou=SomeOU,ou=SomeOtherOU,
Among othger things, you can as well specify the output format using -o, and you can specify the scope to search using -scope.
Check "dsquery -?" or http://technet2.microsoft.com/windowsserver/en/library/46ba1426-43fd-4985-b429-cd53d3046f011033.mspx?mfr=true for details