Solved

Create Users  & mailboxes automatically under win2008 R2 & Exchange 2010

Posted on 2012-12-26
10
389 Views
Last Modified: 2013-01-05
Hello Gurus
I have a win2008 R2 domain controller. I also have another member server which has Exchange 2010.

I have to create 124 Users in 1 specific OU with their mailboxes in Exchange 2010.
I need to set the following settings.
1-User Name & Surname
2-Password ("letmein" for all) - They need to change it on next logon
3-Start up script (some mappings...)
4-Home Folders
5-Enable a Mailbox for those users

I also have a GPO that I need to use for those users.
In fact I have 10 users created and working perfectly as I need the other 124 .
Is there a way to "extract" the settings from those users into a "template" that I could modify to apply on the ones I need to create ?


How Do I do this is Powershell ?

Thanks
0
Comment
Question by:ammounpierre
  • 5
  • 4
10 Comments
 
LVL 7

Expert Comment

by:jimmithakkar
ID: 38723074
0
 

Author Comment

by:ammounpierre
ID: 38723111
I created a file called toadd.ps1 and entered the following in it.

$users = Import-CSV C:\scripts\users.csv
$users| foreach

{

$Password = convertto-securestring $_.password -asplaintext -force

new-mailbox -name $_.name -alias $_.alias -FirstName $_.Firstname -LastName $_.Lastname -userPrincipalName  $_.UPN -database $_.Database -OrganizationalUnit $_.OUpath -Password $Password –ResetPasswordOnNextLogon:$true

}


****************************

Then I created a CSV file and tried to run the command in PS.

Not working !
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38723136
Are you running the script in Exchange Management Shell? if yes what is the error?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 40

Expert Comment

by:Subsun
ID: 38723256
Only problem I see is with the use of foreach, you didn't start the Curly bracket immediately after foreach command..
Try this..
$users = Import-CSV C:\scripts\users.csv
$users| foreach {
$Password = convertto-securestring $_.password -asplaintext -force
new-mailbox -name $_.name -alias $_.alias -FirstName $_.Firstname -LastName $_.Lastname -userPrincipalName  $_.UPN -database $_.Database -OrganizationalUnit $_.OUpath -Password $Password –ResetPasswordOnNextLogon:$true
}

Open in new window

0
 

Author Comment

by:ammounpierre
ID: 38723380
This is the error I am getting while inputing the lines one by one in PS
error.png
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38723391
You are running the script in normal PowerShell, you need to run the script in  Exchange Management Shell.. Also can you post the input csv file? I think you have not provided the tab password in the file or its values are empty..

To open the Exchange Management Shell, follow these steps:

1.Click Start, point to All Programs, and then point to Microsoft Exchange Server 2010.
2.Click Exchange Management Shell.
0
 

Author Comment

by:ammounpierre
ID: 38723463
I launched the Exchange Management Shell and typed in the commands...
Still errors !

Thx
error.png
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38723526
Your CSV file doesn't have a header like..
name,alias,Firstname,Lastname,UPN,OUpath,Database,password

Open in new window

Sample CSV
0
 

Author Comment

by:ammounpierre
ID: 38723575
At last it works !
Thanks a lot !
Still few things...
I would like to add
1-a logon script (scriptstart.bat)
2-Home Folder Z:\ connect to \\data-srv\users\%Username%


Thanks again !!
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38723610
Try this..
Import-Module activedirectory
$users = Import-CSV C:\scripts\users.csv
$users| foreach {
$Password = convertto-securestring $_.password -asplaintext -force
new-mailbox -name $_.name -alias $_.alias -FirstName $_.Firstname -LastName $_.Lastname -userPrincipalName  $_.UPN -database $_.Database -OrganizationalUnit $_.OUpath -Password $Password –ResetPasswordOnNextLogon:$true
Get-ADUser $_.name | Set-ADUser –scriptPath “scriptstart.bat” -HomeDirectory "\\data-srv\users\$($_.name)" -HomeDrive "Z:"
}

Open in new window

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SonicWall blocking access to MS RDP RemoteApp 24 36
Tips on reducing the size of AD (DIT) database 5 32
Fraud Email 22 65
Export AD group members. 1 21
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question