Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DSquery/DSget assistance

Posted on 2007-03-27
3
Medium Priority
?
865 Views
Last Modified: 2012-06-21
I require a dsquery or dsget constructing so that I can obtain a list of users in a particular OU that are not members of 2 specific security groups.  The query should return the user ID and the first and last names.  Is anybody able to assist with this?
0
Comment
Question by:spjo1982
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 total points
ID: 18798909

You know... it might be possible to do that with DS Tools, but it's considerably easier to do in VbScript.

If that approach works for you then save the following as a .vbs file. You will have to fill in the Const values at the top. Run from the command line with "cscript scriptname.vbs" or it'll just pop up lots of boxes.


Const OU = "OU=SomeOU,OU=SomeWhere,DC=YourDomain,DC=com"
Const GROUP_1 = "The First Group Name"
Const GROUP_2 = "The Second Group Name"

Set objOU = GetObject("LDAP://" & OU)
objOU.Filter = Array("user")

For Each objUser in objOU
      strMemberOf = Join(objUser.GetEx("memberOf"))

      If InStr(1, strMemberOf, "CN=" & GROUP_1, VbTextCompare) = 0 And_
                  InStr(1, strMemberOf, "CN=" & GROUP_2, VbTextCompare) = 0 Then

            WScript.Echo objUser.Get("sAMAccountName") & VbTab & objUser.Get("givenName") &_
                  VbTab & objUser.Get("sN")
      End If
Next
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question