karlpearson
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Marvellous
You're welcome :)
ASKER