2

While easy on Linux, not as easy on Windows from what I've been able to gather so far. I've found the command that kinda does what I want which is:

net user username /domain

However I wish to strip all of the data except for the list of the groups. I think findstr may be the answer but I'm not sure of how to use this to do that. Essentially, I guess the script would do something like this (unless there is a more specific command which would be fabulous):

net user username /domain > temp.txt
findstr (or some other command) file.txt > groups.txt
del temp.txt

The output of the data would be a list like this:

group1; group2; group3

Now, I could be going about this a complicated way, so as I mentioned if there is a command that can output ONLY a user's security groups that would be fantastic.

Thanks guys!

Note: asked this on superuser but just found that this site may be more appropriate.

Smitty
  • 23

2 Answers2

2

Not sure if this is the type of thing you're looking for, but I did this on Windows Server 2003 (member server, not an AD DC):

dsquery user -name "My Full Name" | dsget user -memberof | dsget group -samid

This prints out the list of groups I'm a member of line by line (not separated by semicolon).

If you wanted something fancier, you could use VBScript. Let me know if you want an example of that and I can try and find something.

David
  • 3,587
0

You would be better off doing this as an LDAP query then using the net command http://technet.microsoft.com/en-us/library/aa996205(EXCHG.65).aspx

Or there is ADSI

http://msdn.microsoft.com/en-us/library/windows/desktop/aa772170(v=vs.85).aspx

but that could be OTT for what you are after

enterzero
  • 453