9

I would like to list information about all users using drush.

There is user-information, but it shows information only about single user.

Are there any other solutions?

5

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).

4

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.

4

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     :  info@example.com
 User roles    :  authenticated
                  administrator
 User status   :  1
2

For Drupal 8, there is a Drush 9 command on Packagist, e.g.

drush users:list

List all Drupal users in a table format. See drush users:list --help for filtering options.

0

Sorry... wrote this script for Drupal 8 remote machines with aliases; easily adaptable to local if necessary.

if [ $# -lt 1 ]
then
        echo "Usage : $0 sitealias [all/disabled/enabled] [rolename]"
        echo "Note: this only runs on Drupal 8 schema"
        exit
 fi

 ARG1=$1
 ARG2=${2:-all}
 ARG3=${3:-nothing}

 if [ "$ARG3" != "nothing" ]
 then
    ROLEWHERE='AND user__roles.roles_target_id="'$ARG3'"'
 fi



 case "$ARG2" in
    enabled) 
        WHERECLAUSE='WHERE users_field_data.status="1" '$ROLEWHERE
        ;;
    disabled)
        WHERECLAUSE='WHERE users_field_data.status="0" '$ROLEWHERE
        ;;
    all)
        WHERECLAUSE='WHERE users_field_data.status LIKE "%" '$ROLEWHERE
        ;;
    *)
        WHERECLAUSE=''
        ;;
 esac

 QUERY='SELECT users_field_data.uid,users_field_data.name,users_field_data.mail,from_unixtime(users_field_data.login) AS "lastlogin",user__roles.roles_target_id,users_field_data.status FROM users_field_data LEFT JOIN user__roles ON users_field_data.uid = user__roles.entity_id '$WHERECLAUSE

 drush $1 sqlq "$QUERY"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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