Skip to content

Instantly share code, notes, and snippets.

@synackme
Last active February 16, 2016 03:38
Show Gist options
  • Save synackme/e62a1e8386d72a95e0e4 to your computer and use it in GitHub Desktop.
Save synackme/e62a1e8386d72a95e0e4 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys, subprocess, getopt
if len(sys.argv) != 2:
print "Usage: osx_add_user_to_group.py <user>"
sys.exit(1)
for arg in sys.argv[1:]:
bashCommand1 = "sudo dseditgroup -o edit -a %s -t user admin" % sys.argv[1]
bashCommand2 = "sudo dseditgroup -o edit -a %s -t user wheel" % sys.argv[1]
process = subprocess.Popen(bashCommand1.split(), stdout=subprocess.PIPE)
output = process.communicate()[0]
process = subprocess.Popen(bashCommand2.split(), stdout=subprocess.PIPE)
output = process.communicate()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment