Yes, I have tested it here (but only after you asked). I only have one user so it's not a very thorough test case.
Do you get an error, or doesn't it do what you expect?
Where do you want the real name to be displayed?
Code:
#!/bin/bash
users | tr '. ' '
' | sort -u | while read user
do
sed -n "s/:[^:]*:[^:]*$//;s/^$user:[^:]*:[^:]*:[^:]*://p" /etc/passwd
ps -U "$user"
done