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 solution?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityFor 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
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.
drush uinf $(drush sqlq "SELECT GROUP_CONCAT(uid) FROM users LIMIT 99999")
PS: Currently I do not have a Drupal-installation at hand, so I can now test for myself, sorry :-(
Dec 4, 2020 at 12:16
drush uinf --uid=$(drush sqlq "SELECT GROUP_CONCAT(uid) FROM users")
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).
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.
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"