Last active
May 3, 2016 19:59
-
-
Save gravejester/3ec28a6098fe24a65a9c72bfdb081f92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$adPath = 'OU=Users,OU=Dev,DC=test,DC=local' | |
$adDomain = 'test.local' | |
$userPassword = 'aV3ryl0ng-and.securePASSWORD!!' | |
$users = Get-RandomUser -Amount 30 -Nationality gb,uk -ExcludeFields picture | Select-Object -ExpandProperty results | |
foreach ($user in $users) { | |
$newUserProperties = @{ | |
Name = "$($user.name.first) $($user.name.last)" | |
GivenName = $user.name.first | |
Surname = $user.name.last | |
Path = $adPath | |
AccountPassword = (ConvertTo-SecureString $userPassword -AsPlainText -Force) | |
SamAccountName = $user.login.username | |
UserPrincipalName = "$($user.login.username)@$($adDomain)" | |
Enabled = $true | |
} | |
try {New-ADUser @newUserProperties} catch {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment