Re: Query to extract only those group members with enabled accounts
- From: Jerold Schulman <Jerry@xxxxxxxxxx>
- Date: Tue, 12 Dec 2006 21:03:08 -0500
On 12 Dec 2006 13:42:03 -0800, mail269618@xxxxxxxxxxxxxxxx wrote:
I would like to extract a list of the members of an AD group, but only
include those with enabled accounts (i.e. anyone whose account is not
disabled).
work, however I wanted to check my logic and my code before I try it asFrom my reading here and elsewhere, I believe that the following should
I don't have a test machine at the moment.
dsquery * domainroot -filter
"(&(objectcategory=person)(objectclass=user)(!useraccountcontrol:1.2.840.113556.1.4.803:=2))"
| dsget group "CN=GroupName,DC=domain name,DC=com" -members >
c:\temp\list.txt
I thought that my logic was sound - using dsquery to find non-disabled
accounts and then piping that to dsget to retrieve members of the
group.
I modified the dsquery example from
http://www.jsifaq.com/SF/Tips/Tip.aspx?id=9815 and piped it's output to
a dsget example from the online help, suggesting the format is dsget
group "<GroupDN>" -members.
Should this work? Any suggested improvements? Thanks for your input.
No.
Your querying users and piping to a group!
This batch works.
@echo off
setlocal
for /f "Tokens=*" %%a in ('dsget group "CN=GroupName,DC=domain name,DC=com" -members') do (
for /f "Tokens=*" %%b in ('dsget user %%a -disabled^|find "no"') do (
@echo %%a
)
)
endlocal
Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
.
- Follow-Ups:
- Re: Query to extract only those group members with enabled accounts
- From: mail269618
- Re: Query to extract only those group members with enabled accounts
- References:
- Query to extract only those group members with enabled accounts
- From: mail269618
- Query to extract only those group members with enabled accounts
- Prev by Date: Re: how to restrict users to search in their own Organizational Unit
- Next by Date: Upgrading large distributed environment from AD2000 to AD 2003 - Risks, Challenges
- Previous by thread: Query to extract only those group members with enabled accounts
- Next by thread: Re: Query to extract only those group members with enabled accounts
- Index(es):
Relevant Pages
|