Import-Module ActiveDirectory
$ou = "OU=Full-Time Employees,OU=Dogtoe,DC=dogtoe,DC=local"
$firstNames = @("Charles","John", "Jane", "Bob", "Alice", "Emily", "Michael", "Sarah", "David", "Jimmie")
$lastNames = @("Doe", "Smith", "Johnson", "Brown", "Williams", "Jones", "Garcia", "Miller")
$numUsers = 50
for ($i = 1; $i -le $numUsers; $i++) {
$firstName = $firstNames | Get-Random
$lastName = $lastNames | Get-Random
$username = "$($firstName.ToLower()).$($lastName.ToLower())"
$EmailAddress = "$username@dogtoe.com"
$UserPrincipalName = "$username@dogtoe.local"
$password = "P@ssw0rd" + (Get-Random -Minimum 100 -Maximum 999)
New-ADUser -Name "$firstName $lastName" `
-GivenName $firstName `
-Surname $lastName `
-UserPrincipalName $UserPrincipalName `
-SamAccountName $username `
-EmailAddress $EmailAddress `
-AccountPassword (ConvertTo-SecureString $password -AsPlainText -Force) `
-Enabled $true `
-Path $ou
Write-Host "Created user $username with password $password"
}
activedirectory
password
powershell
random
user
useraccount
users
windows
windowsserver
Be the first to comment on this post!
Your personal data is secure.
Learn about how your information is collected, used, and securely stored in the Privacy Policy.