Category Archives: cmd

GNU utilities native in windows

For all you Linux fans out there, that use a lot of linux commands (sed,ls,awk,etc) and would like to have this also on linux, you can give UnxUtils a try. The big differences between UnxUtils and Cygwin is that UnxUtils uses executables that are only dependent to Microsoft C-runtime (msvcrt.dll).

All you have to do is:

1. Download the zip file from owners site

2. Unzip the file in any location (preferably C:\Program Files (x86)\UnxUtils )

3. Add the path C:\Program Files (x86)\UnxUtils\usr\local\wbin to the System Variables PATH (Start – Control Panel – System – Advanced system settings – Advanced – Environment Variables – System variables – PATH – edit)

You can find a complete list of programs that are ported on the UnxUtils site.

List users in an AD group

If you want to quickly list all the users in a group (and even count them) you need the DN name of the group and the following line entered in cmd or PowerShell:

dsget group "CN=Group,DC=Contoso,DC=com" -members -expand

This will list all the users/groups that are members of that group. To find out the number of members pipe the output to find using the c switch (all DN have a DC in their name):

dsget group "CN=Group,DC=Contoso,DC=com" -members -expand | find /c "DC"

Hint: If you use a special syntax for groups (group_groupname or abreviation_groupname) you can exclude all the groups (using find’s v switch) and you will find only the users in that group.

dsget group "CN=Group,DC=Contoso,DC=com" -members -expand | find /c /v "group_"