What steps are needed to create a new user from the command line? What commands (or script) can create a fully functional user account on Mountain Lion, running only from the command line via terminal or ssh.

It looks like an existing pair of answers might work, but I wondered if there were a short script or tool for creating fully functional user accounts on Mountain Lion?
Here is a shell script I wrote at work to handle this as part of the NetInstall process (creating a local administrator account automatically during imaging process).

#!/bin/sh
. /etc/rc.common
dscl . create /Users/administrator
dscl . create /Users/administrator RealName "Administrator Account"
dscl . create /Users/administrator hint "Password Hint"
dscl . create /Users/administrator picture "/Path/To/Picture.png"
dscl . passwd /Users/administrator thisistheaccountpassword
dscl . create /Users/administrator UniqueID 501
dscl . create /Users/administrator PrimaryGroupID 80
dscl . create /Users/administrator UserShell /bin/bash
dscl . create /Users/administrator NFSHomeDirectory /Users/administrator
cp -R /System/Library/User\ Template/English.lproj /Users/administrator
chown -R administrator:staff /Users/administrator


Some notes to mention:


I have this saved as an executable ".sh" file.
Since it executes during NetInstall it runs as root, and needs to run as root to work properly. You can also subtract the first two lines, add a "sudo" to the beginning of each subsequent line, and manually run these as individual commands in Terminal.
Modify UniqueID from 501 to a number that you will know is safe on all systems (501 is taken by the first account created on a Mac, generally something higher like 550 will probably be safe, depending on how many users you have on your system).
PrimaryGroupID of 80 creates an Admin user. Change to PrimaryGroupID of 20 to create a Standard user.
I've imaged well over 50 Macs this way with no issues. I use this account to run commands via SSH, to push out patches via ARD and to do local desk-side administration.