Link to home
Start Free TrialLog in
Avatar of karlpearson
karlpearsonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

DSGET DSQUERY question

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.
ASKER CERTIFIED SOLUTION
Avatar of Krzysztof Pytko
Krzysztof Pytko
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of karlpearson

ASKER

Thank you sir works great.
Marvellous
You're welcome :)