We help IT Professionals succeed at work.
Get Started

DSGET DSQUERY question

2,187 Views
Last Modified: 2012-05-10
All,

I am tyring to write a batch file that will output  a list of groups for a given list of usernames. The usernames are contained in a text file and are samiid (windows logon name) there are hundreds of users in the text file. I have so far gotten this working with the following script:-

for /f "tokens=* delims=," %%I in (users.txt) do call :sub1 %%I
:sub1
dsquery user -samid %1 | dsget user -memberof -expand | dsget group -samid >> "groups.txt"

My issue is that when this groups.txt file is created it contains unwanted text namely, samid at the start of the groups output and dsget succeeded at the bottom for each user. All I wanted was just a list of groups without this in, as this groups.txt file is going to be the input for a further batch file.

I wanted to try and this in batch as I understand it more than anything else so it would be appreciated if we could stick to batch but fully understnad if that is not possible due to this being data manipulation,

Hope someone can help.
Comment
Watch Question
Senior Active Directory Engineer
CERTIFIED EXPERT
Top Expert 2012
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE