Sometimes you may find that you need to export the list of which security and distribution groups a user belongs to into a text file. This is sometimes done for auditing purposes and sometimes required because that amount of text in a CMD prompt is just oo hard to navigate.
![Easy way to ouput what user a group belongs to into a text file](https://www.urtech.ca/wp-content/uploads/2023/09/Easy-way-to-ouput-what-user-a-group-belongs-to-into-a-text-file-1024x373.jpg)
As you can see in the screenshot above, we are using the whoami command, but you can also use net user as we explain here.
- whoami returns the current username
- whoami /groups returns a complete list of all groups that user belongs to
- whoami /groups > c:\temp\test1.txt creates a file that contains all of the groups the user belongs to
0 Comments