Sometimes that is not feasible, and sometimes you want to just script things.
For those, you can use the Windows net localgroup command (if you have sufficient privileges, you can even apply it to the local groups on your domain controller by appending it with the /domain parameter, or use the net group /domain command to execute on global domain groups instead of local groups).
Sample of using this in a cmd script:
net localgroup Guests Me Myself I ACME\BugsBunny /delete
It will remove the local users Me, MySelf and I, and remove the domain user ACME\BugsBunny from the local group Guests.
Sample source of using this in Delphi: Read the rest of this entry »