Active Directory, Windows Administration

Creating Fake Users Active Directory (Test Environment)

November 28, 2016

One of the annoyances that you generally don’t have with Production is…. Creating People!

You have this nice new test environment that has absolutely nobody in it and you want to fix that.

If you go over to http://www.fakenamegenerator.com/ you can submit a job to get most of the information you are going to need. Get a CSV file from the “Order in Bulk” tab. For my purposes I created 10,000 users. In the future I may generate another 10,000 or so and database the names so I can generate my own.

From here I cleaned up the CSV and did an import into PowerShell and ran each one through a ForEach loop and created my users in the proper location. I’ve attached the script below.

# Create User Accounts

Import-Module ActiveDirectory

$Users = Import-CSV C:\Users\en_scripting_adm\Desktop\FakeNames.csv

ForEach ($user in $Users)
{
$givenName = $user.GivenName
$mi = $user.MI
$surname = $user.Surname
$streetAddy = $user.StreetAddress
$city = $user.City
$email = $user.EmailAddress
$username = $user.Username
$pass = ConvertTo-SecureString “Temp1234” -AsPlainText -Force
$upn = $username + “@domain.suffix”
$displayN = $givenName + ” ” + $surname

$var = $username.substring(5,1)
$firstOU = “OU=Users ” + $var

$path = “$firstOU,OU=Users,OU=Staging,OU=_Delegated,DC=domain,DC=suffix”

Write-Host “Creating User $username”

New-ADUser -Name $username -GivenName $givenName -Enabled $true -Surname $surname -StreetAddress $streetAddy -city $city -EmailAddress $email -UserPrincipalName $upn -AccountPassword $pass -DisplayName $displayN -path $path
}

You Might Also Like

No Comments

Leave a Reply