Reputation: 8374
How would one add a group of users to Active Directory from a csv file using PowerShell?
The csv file would contain the first, last, email, temp password, and description for the users. The OU, permissions, and etc. could be hard coded.
The script should also add an Exchange 2007 email box.
Upvotes: 0
Views: 11946
Reputation: 8374
The csv file should contain a header row with all the field names.
Here is the code:
$Users = Import-Csv ".\UsersFile.csv"
foreach ($User in $Users)
{
New-Mailbox -Name $User.Name -Alias $User.MailboxAlias `
-OrganizationalUnit $User.OU `
-UserPrincipalName $User.UPN -SamAccountName $User.UserName `
-FirstName $User.First -Initials $USer.Initial -LastName $User.Last `
-Password $User.Password -ResetPasswordOnNextLogon $false `
-Database 'MailboxDatabaseFilename'
}
Upvotes: 1
Reputation: 31928
Create a new user (From here)
$newUser = $usersOU.Create("user","cn=MyNewUser")
$newUser.put("title", "PowerShell Test Account")
$newUser.put("employeeID", 123)
$newUser.put("description", "Test User Account for LazyAdmin Demo")
$newUser.SetInfo()
Using Import-CSV cmdlet (its PowerShell 2.0, but mostly relevant to 1.0)
Upvotes: 1