Drupal - How to list all users in drush?

For Drupal 8 you could run the following command:

drush uinf $(drush sqlq "SELECT GROUP_CONCAT(name) FROM users_field_data")

The output will loke something like the following:

 User ID       :  1
 User name     :  admin
 User mail     :  [email protected]
 User roles    :  authenticated
                  administrator
 User status   :  1

There is recent sandbox project: Drush User List (by John) which should work for Drupal 6 & 7 (see GitHub).

Usage:

drush user-list

For other workaround, the following command with process substitution syntax should help:

drush uinf $(drush sqlq "SELECT GROUP_CONCAT(name) FROM users")

However it could fail in some cases (when users have some special characters in their name).


As kenorb pointed out, there is a workaround via SQL-query.

And with a minor change, it becomes more robust to special characters in names - by using "uid" (integer) instead of the user-names:

drush uinf $(drush sqlq "SELECT GROUP_CONCAT(uid) FROM users")

PS: Confirmed for Drupal 7 only.
PPS: Sorry for adding another answer, I can not comment yet.

Tags:

Drush

Users

7

6