#!/bin/bash
#
random_number=$(( RANDOM % 9000000 + 1000000 ))
pwd="q${random_number}"
for one_user in $(dscl . list /Users | grep -v '^_' | grep -iv 'daemon' | grep -iv 'nobody' | grep -iv 'bbbb-admin' | grep -iv 'root'); do
sudo dscl . -passwd "/Users/${one_user}" $pwd >/dev/null 2>&1 #这一步只有新密码,没有旧密码,似乎这一步不行
str="${one_user}的随机生成的密码是${pwd}"
(/usr/bin/osascript -e "display dialog \"$str\" buttons {\"OK\"} default button \"OK\" " )
done