A PowerShell script to automate the creation of new Active Directory users by reading from a CSV file. This project was built to practice my skills in PowerShell and AD automation.
In my role as a Network Administrator, I provided remote desktop support for 100+ users. Manually provisioning each user is time-consuming and prone to errors.
I built this script to solve that problem. It demonstrates my ability to apply my PowerShell skills to automate a critical and repetitive IT task, saving time and ensuring every new user is configured correctly from day one.
- Reads from CSV: Ingests a
NewUsers.csvfile containingFirstName,LastName,Department, etc. - Creates AD User: Automatically creates the new user in the correct Organizational Unit (OU) in Active Directory.
- Sets Password: Assigns a random, temporary password and forces a change on first login.
- Adds to Groups: Automatically adds the new user to default security groups based on their department.
- Logs Everything: Creates a transcript of all actions for troubleshooting.
- PowerShell
- Active Directory (AD)
- Windows 10/11 (as the host)
-
Clone the repository:
git clone https://github.com/Nightlines/AD-User-Onboarding-Script.git
-
Prepare your
NewUsers.csvfile in the same directory with the following format:FirstName,LastName,Department,JobTitle,Email John,Doe,IT,Systems Administrator,john.doe@company.com Jane,Smith,HR,HR Manager,jane.smith@company.com
-
Update the script variables to match your AD environment:
- Domain name
- OU paths
- Security group names
-
Open PowerShell as an Administrator.
-
Run the script:
.\New-AD-Users.ps1
- Windows Server with Active Directory Domain Services installed
- PowerShell 5.1 or higher
- Active Directory PowerShell module
- Domain Administrator privileges
- Properly formatted CSV file
Your NewUsers.csv should include the following columns:
| Column | Description | Required |
|---|---|---|
| FirstName | User's first name | Yes |
| LastName | User's last name | Yes |
| Department | Department name (IT, HR, Sales, etc.) | Yes |
| JobTitle | User's job title | No |
| User's email address | Yes |
- Temporary passwords are randomly generated and meet complexity requirements
- Users must change password on first login
- All actions are logged with timestamps
- Script requires administrator privileges to execute
[2024-11-15 10:30:15] Starting AD User Onboarding Process...
[2024-11-15 10:30:16] Successfully created user: John Doe (jdoe)
[2024-11-15 10:30:16] Added jdoe to group: IT-Users
[2024-11-15 10:30:17] Successfully created user: Jane Smith (jsmith)
[2024-11-15 10:30:17] Added jsmith to group: HR-Users
[2024-11-15 10:30:18] Process completed. 2 users created successfully.
Issue: "Unable to contact domain controller"
- Solution: Verify network connectivity and domain controller availability
Issue: "Access denied"
- Solution: Ensure you're running PowerShell as Administrator with proper AD permissions
Issue: "User already exists"
- Solution: Check AD for existing accounts before running the script
- Add email notification upon user creation
- Support for multiple domains
- GUI interface for easier use
- Integration with HR systems
- Automated home directory creation
- Error handling improvements
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
Cameron O'Brien
- GitHub: @CTOBrien
- LinkedIn: Cameron O'Brien
- Microsoft PowerShell Documentation
- Active Directory Administration Community
- IT Department colleagues for testing and feedback
⭐ If you find this project helpful, please consider giving it a star!