Link to home
Start Free TrialLog in
Avatar of Tech Man
Tech ManFlag for United States of America

asked on

Bulk AD user and Exchange 2010 mailbox creation from CSV file -Powershell

Hi, I have big list of new users that I need to create in Active Directory as well as mailboxes. I have CSV file that I would like to use.
Forest functional level Windows Server 2008R2. I have to domain Controllers (2008R2 and 2012)
Exchange 2010

This is what I have:
This is Script:

$Users = Import-Csv "C:\Scripts\MailboxUsers.csv"
 
ForEach-Object ($User in $Users) {
New-Mailbox -Name $user.'name' -Alias $user.'alias' -UserPrincipalName $user.'userPrincipalName' -FirstName $user.'firstName' -LastName $user.'lastName' -DisplayName $user.'displayName' -Database $user.'database'  –OrganizationalUnit $user.'ParentOU' -Password (ConvertTo-SecureString 'MyPassword123' -AsPlainText -Force)    -ResetPasswordOnNextLogon $True
}
 This is how my CSV look like:


Please see attached CSV and Screenshot of the error in powershell

I would appreciate any help.
myCSV.png
MyError.png
ASKER CERTIFIED SOLUTION
Avatar of Learner
Learner
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tech Man

ASKER

I tried to use this script before I created the one I am showing.. I don't exactly remember the details but it does not work. Please advise.

Thank you
use ForEach instead of foreach-object
Vaseem, Do you mean on my script that I have posted initially?
Thanks, I will try.
did u get it working or still having some issues?