Tech Man
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.c sv"
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
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.c
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use ForEach instead of foreach-object
ASKER
Vaseem, Do you mean on my script that I have posted initially?
Yes
ASKER
Thanks, I will try.
did u get it working or still having some issues?
ASKER
Thank you