Skip to content

Bulk-create mock Active Directory users and import them into a Domain Controller using Powershell and Python!

License

Notifications You must be signed in to change notification settings

Michael-Free/CreateADUsers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CreateADUsers

CreateADUsers provides a powerful framework generating and deploying test user data in an Active Directory environment. These scripts save time, reduce errors, and provide flexibility for testers, IT departments, and homelabbers alike.

Whether you're testing a new system, onboarding employees, or experimenting in a homelab, these scripts are a valuable tool for managing user data efficiently.

Prerequisites

  • Active Directory Environment:

    • A Windows Server with Active Directory Domain Services (AD DS) installed and configured.
    • Administrative access to the domain.
  • PowerShell:

    • PowerShell 5.1 or later installed on the server.
    • The Active Directory module for PowerShell (installed via RSAT-AD-PowerShell).
  • Python:

    • Python 3.x installed (for running the user generation script).
    • The faker library installed (pip install faker).
  • Permissions:

    • Administrative privileges on the server to create AD users.
    • Write permissions to the directory where the CSV file will be saved.
  • Basic Knowledge:

    • Familiarity with PowerShell and Python scripting.
    • Understanding of Active Directory user management concepts.

Installation

There are two ways to install the CreateADUsers repository:

  1. Direct Repository Sources
  • Clone this repository using Git or download the ZIP file.
  • Extract the contents of the ZIP file to a directory on your computer.
  • Open PowerShell as an administrator and navigate to the directory where you extracted the repo files.
  • Run the respective createusers.py and addusers.ps1 scripts.
  1. Download Official Releases from GitHub
  • Navigate to the latest release on Github by clicking on Releases (or by clicking here) .
  • Download addusers.exe and createusers.exe
  • Run these respective binary files via your terminal of choice.

Usage

The two scripts provided are designed to work together to quickly create and import Active Directory (AD) user accounts in a test environment.

The first script, createusers.ps1, generates randomized CSV data for AD user attributes such as first name, last name, email address, job title, department, etc.

The second script, addusers.ps1, takes the CSV file generated by the first script and uses it to create new AD user accounts in a specified domain.

createusers.py

This script creates random users and their associated data, including a SamAccountName, email address, and password. The script can be run with any number of users as an argument, and will create that many users in a CSV file called "random_users.csv". The script uses the Faker library to generate fake data for each user, and the random module to randomly select a department and office location.

Dependencies

The script requires the following dependencies:

  • faker
  • random
  • sys
  • os
  • string

Example

To use this script, simply run it with an integer as an argument representing the number of users you want to create. For example, to create 10 users, you can run the script as follows:

python3 createusers.py 10

The script will create a CSV file called "random_users.csv" in the current working directory, containing the generated user data. You can open this file using a spreadsheet program or other tool to view and manipulate the data.

addusers.ps1

This script imports a list of user account details from a CSV file and creates corresponding Active Directory user accounts. It validates prerequisites, including administrative privileges, operating system type, and input data formats, before attempting to create accounts. Accounts are created with attributes such as display name, email address, department, and more.

Dependencies

  • Windows Server
  • Administrative Privileges
  • Active Directory Module for PowerShell
  • Domain-Joined Machine
  • PowerShell 5.1 or newer

Example

.\addusers.ps1 -CsvPath "C:\path\to\random_users.csv" -Domain "example.com"

If successful:

All users created successfully!

If some users fail to create:

Some users failed to create:
User       Error
----       -----
jsmith     The specified user already exists

License

Free Custom License (FCL) v1.0

Copyright 2025, Michael Free. All Rights Reserved.

Contributions

Reporting Bugs

If you encounter any issues while using the tool, please report them in the issue tracker on GitHub. Be sure to include the following information in your bug report:

  • The steps to reproduce the issue
  • The expected behavior
  • The actual behavior
  • Any error messages or stack traces associated with the issue

Requesting Features

If you have an idea for a new feature, please let me know by creating an issue in the issue tracker on GitHub. Be sure to explain why this feature would be useful and how it could benefit the project.

Contributing Code

If you're a developer interested in contributing code to the project, I encourage you to submit a pull request through GitHub. Before submitting your code, please make sure it adheres to my coding standards and passes any automated tests.

Providing Feedback

Your feedback is valuable to me. If you have any suggestions or ideas for improving the tool, please share them with me through the issue tracker on GitHub or by reaching out to me on Mastodon: https://mastodon.social/@MichaelFree

Testing and Quality Assurance

I appreciate any help testing the project and reporting issues. If you have experience in testing, please let me know by creating an issue in the issue tracker on GitHub or by contacting me directly.

Thank you for your interest in contributing to my project! Your contributions will help make it even better.

About

Bulk-create mock Active Directory users and import them into a Domain Controller using Powershell and Python!

Topics

Resources

License

Stars

Watchers

Forks