Skip to main content
Background Image

home.lab: Adding users (part 4)

·362 words·2 mins

Wow, our AD Domain sure looks shiny and new :-) It is time to add some users and groups to my lab. I’m lazy so I just used list of random names I found from internet and scripted the adding process.

Adding domain users
#

Names

$ cat names
  Atreus Peters
  Leila Little
  Lennox Olson
  Isabel McCormick

$ cat create-users.sh
#!/bin/bash
IFS=$'\n'
for line in $(cat names); do
    uname=$(echo $line | awk {'print $1'});
    echo "net user $uname Password1 /fullname:$line /domain /add";
done

$ chmod +x create-users.sh 
$ ./create-users.sh > addusers.bat
$ cat addusers.bat
net user Atreus Password1 /fullname:Atreus Peters /domain /add
net user Leila Password1 /fullname:Leila Little /domain /add
net user Lennox Password1 /fullname:Lennox Olson /domain /add
net user Isabel Password1 /fullname:Isabel McCormick /domain /add

Now all we have to do is to transfer this addusers.bat file to domain joined computer and execute it. Easiest way to do this is just copy-paste script to target computer and run it. If for some reason that is not possible, I’ll recommend that you use python’s http.server module and download the script file with the browser.

Start HTTP service with python

$ python3 -m http.server 8080
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...

now use your domain joined Windows 10 client and download addusers.bat script.

Remember to run addusers.bat from elevated shell, otherwise script execution might fail.

Adding domain groups
#

Almost every real world organisation has different organisational units that perform different functions. Our test lab will have only few:

  • HR
  • Dev
  • Marketing

Easiest way to add OU is to use GUI-tool “Active Directory Users and Computers”

home.lab -> New -> Organizational Unit -> Name -> give name to your new OU.

After OU has been created you can add users by right clicking OU name.

Snapshots
#

Now the basic setup is finished and we are ready to play with our new lab environment. I use snapshots quite heavily to have an easy recovery plan when something goes wrong. Remember we are here to learn and have fun, not nessecerily practicing disaster recovery :-D

Ok, that’s it. Hopefully you got something out of this and I’ll see you in next post.