Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to alter the logon.bat script for our AD users (Windows XP/vista/7 machines and a few servers), so that it writes an environmental variable upon login based on some AD information, like "what group is the user in".

Basically: SET MyADGroup=<some magic query/command that can get that AD information here>

Some Google searches got me into dsget and so on, but that was only on servers and not built into any "normal client".

share|improve this question
This seems silly for any number of reasons - including the fact that a user might be in more than one group. Can you tell us what problem you're actually trying to solve? – mfinni May 12 '11 at 13:00

You can get a list of the groups a user belongs to using the "NET USER" command:

net user <username> /domain

The command provides lots of informations, including group membership; but storing that in a variable can get tricky, because you would need to parse the command's output.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.