Thanks for the feedback, Steve.
As for the "user" part of this, we also used similar code to create the code at the DOS level to create the AD users and add them to a group for the "load testing" that we do once a quarter. We also generated similar code to undo all of it.
And, of course (you know me), we executed all of it through calls to xp_CmdShell.
--Jeff Moden
Change is inevitable... Change for the better is not.