Share this post!

Ever wanted to create a number of Active Directory test user accounts, but didn’t want to use incrementing accounts like Test01, Test02, Test03, etc.? I’ve often used United States presidents and vice presidents for my test accounts. The usernames are far more interesting that way! For anyone who would like to do the same, I’ve created a very simple PowerShell script, that simply needs two lines modified at the top, to be reusable for other environments. Once run against Active Directory, you’ll have 77 accounts that can be nested into groups or used for various testing functions. Check it out and enjoy!

Update: I asked Chat GPT to build me some inline documentation for the script and it did a pretty decent job!

# Set the domain name for the user accounts
$userdomain = "mydomain.com"

# Set the organizational unit path for the user accounts
$organizationalunitpath = "ou=Politicians,ou=users,ou=company,dc=mydomain,dc=com"

# Define an array of politician names
$politicians = @(
("John","Adams"),
("Chester","Arthur"),
("Joe","Biden" ),
("James","Buchanan"),
("Martin","Buren"),
("George","Bush"),
("Jimmy","Carter"),
("Grover","Cleveland"),
("Bill","Clinton"),
("Calvin","Coolidge"),
("Dwight","Eisenhower"),
("Millard","Fillmore"),
("Gerald","Ford"),
("James","Garfield"),
("Ulysses","Grant"),
("Warren","Harding"),
("William","Harrison"),
("Benjamin","Harrison"),
("Rutherford","Hayes"),
("Herbert","Hoover"),
("Andrew","Jackson"),
("Thomas","Jefferson"),
("Lyndon","Johnson"),
("Andrew","Johnson"),
("John","Kennedy"),
("Abraham","Lincoln"),
("James","Madison"),
("William","McKinley"),
("James","Monroe"),
("Richard","Nixon"),
("Barack","Obama"),
("Franklin","Pierce"),
("James","Polk"),
("Ronald","Reagan"),
("Franklin","Roosevelt"),
("Theodore","Roosevelt"),
("William","Taft"),
("Zachary","Taylor"),
("Harry","Truman"),
("Donald","Trump"),
("John","Tyler"),
("George","Washington"),
("Woodrow","Wilson"),
("Aaron","Burr"),
("Adlai","Stevenson"),
("Al","Gore" ),
("Alben","Barkley"),
("Charles","Curtis"),
("Charles","Dawes"),
("Charles","Fairbanks"),
("Dan","Quayle"),
("Daniel","Tompkins"),
("Dick","Cheney"),
("Elbridge","Gerry"),
("Garret","Hobart"),
("George","Clinton"),
("George","Dallas"),
("Hannibal","Hamlin"),
("Henry","Wallace"),
("Henry","Wilson"),
("Hubert","Humphrey"),
("James","Sherman"),
("John","Breckinridge"),
("John","Calhoun"),
("John","Garner"),
("Kamala","Harris"),
("Levi","Morton"),
("Mike","Pence"),
("Nelson","Rockefeller"),
("Richard","Johnson"),
("Schuyler","Colfax"),
("Spiro","Agnew"),
("Thomas","Hendricks"),
("Thomas","Marshall"),
("Walter","Mondale"),
("William","King"),
("William","Wheeler")
)

# Import the Active Directory module
Import-Module ActiveDirectory

# Loop through each politician in the array
foreach ($politician in $politicians){

# Extract the first and last name of the politician from the array
$firstname = $politician[0]

$lastname = $politician[1]

# Construct the username for the politician
$username = "$firstname.$lastname"

# Construct the user principal name for the politician
$userprincipalname = "$username@$userdomain"

# Write a message to the console indicating that a user account is being created
Write-host "Creating user account for $username"

# Create a new Active Directory user account
New-ADUser -Name $username `
-UserPrincipalName $userprincipalname `
-GivenName $firstname `
-Surname $lastname `
-Path $organizationalunitpath `
-Enabled $true `
-PasswordNotRequired $true
}

Share this post!