Skip to content

Instantly share code, notes, and snippets.

@gravejester
Last active May 3, 2016 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravejester/3ec28a6098fe24a65a9c72bfdb081f92 to your computer and use it in GitHub Desktop.
Save gravejester/3ec28a6098fe24a65a9c72bfdb081f92 to your computer and use it in GitHub Desktop.
$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