As network engineers and technicians, we often rely on Wireshark to troubleshoot and analyze network…
Active Directory How to bulk create demo user
I’m right now preparing a lab environment and need some ad account for represent user of different departments.
As I was not able to find something in google which does create the users in the way I like, I decided to write up something in my own.
As it is maybe useful to some of you guys, here it is 🙂
#Globalconfig
$password = "S3cr3tP@ssw0rd!"
$departments = @("Sales", "Helpdesk", "Engineers", "User", "Manager", "Admin", "Test", "User")
$OrganisationUnit = "OU=GlobalUser,dc=adnlab,dc=local"
#userconfig
$UserOrganization = "ADNLab"
$UserUPNsuffix = "@adnlab.local"
$UserEmailsuffix= "@adnlab.local"
$UserChangePasswordatLogon = $false
$UserCity = "Bochum"
$UserPostalCode = "44688"
$UserState = "NRW"
$UserStreetAddress = "Josef-Haumann-Str. 10"
$UserCountry = "DE"
$UserCompany = "ADNLab"
$UserPasswordNeverExpires = $true
$securepassword = ConvertTo-SecureString -AsPlainText $password -Force
foreach ($usertype in $departments) {
1..7 | foreach {
New-ADUser -Name "$usertype $_"-SamAccountName $usertype$_ -UserPrincipalName $usertype$_$UserUPNsuffix -Organization $UserOrganization -Department $usertype -Surname $_ -EmailAddress $usertype$_$UserEmailsuffix -ChangePasswordAtLogon $UserChangePasswordatLogon -City $UserCity -PostalCode $UserPostalCode -State $UserState -DisplayName "$usertype $_" -Company $UserCompany -StreetAddress $UserStreetAddress -Country $UserCountry -GivenName $usertype -PasswordNeverExpires $UserPasswordNeverExpires -AccountPassword $securepassword -Enabled $true -Title $usertype -Path $OrganisationUnit
}
}
Comments (0)