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.
Microsoft DOSActive DirectoryWindows Server 2003

Avatar of undefined
Last Comment
Krzysztof Pytko

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Krzysztof Pytko

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
karlpearson

Thank you sir works great.
ASKER
karlpearson

Marvellous
Krzysztof Pytko

You're welcome :)
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23