Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can I create a vbs script the will use DSQuery and DSGet to find if a user is in a group?

Posted on 2007-11-13
3
Medium Priority
?
2,364 Views
Last Modified: 2012-05-05
Can I create a vbs script the will use DSQuery and DSGet to find if a user is in a group?

What I want to do is take user ids from a txt file and first use DSQuery to see if they are in the Domain then use DSGet to see if they are in a group. If they are not in the group out put the user ID to a text file.

So is this doable in a vbs script?
0
Comment
Question by:pointhigh
3 Comments
 
LVL 11

Expert Comment

by:bsharath
ID: 20277278
Is it that you want to find users in the txt file if they are a member of any group.?
0
 
LVL 3

Accepted Solution

by:
elissaqp earned 750 total points
ID: 20277551
This is an example of "Returns the members of an Active Directory group named Scientists."

On Error Resume Next
 
Set objGroup = GetObject _
  ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")
objGroup.GetInfo
 
arrMemberOf = objGroup.GetEx("member")
 
WScript.Echo "Members:"
For Each strMember in arrMemberOf
  WScript.echo strMember
Next


If you need to write info on a txt file, this is an example:

Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\scripts\service_status.txt", ForAppending, True)
Set colServices =  GetObject("winmgmts:").ExecQuery _
    ("Select * from Win32_Service")
For Each objService in colServices    
    objTextFile.WriteLine(objService.DisplayName & vbTab & _
        objService.State)
Next
objTextFile.Close

0
 

Author Comment

by:pointhigh
ID: 20289820
That looks like a good solution
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

885 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