Solved

Exchange 2010 create mail enabled users from a csv file

Posted on 2011-09-12
23
1,985 Views
Last Modified: 2012-05-12
Hi

I need to create some New mail enabled users (Not new users with Mailboxes) in Exchange 2010.

I can find plenty of articles telling me how to create new users with mailboxes via Powershell but I just need to create mail enabled users.  All these users have email addresses external to our company but need to be given AD logons to our Domain.

I have a CSV file containg the users full names, alias, email address, phone number, job title and manager and would like to import as much of this information as possible. but at a minimum, First name, Last name, alias and email address.

Can someone please point me in the right direction.

 
0
Comment
Question by:cmiadmin
  • 12
  • 11
23 Comments
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
you would be looking for new-mailuser
0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
sorry i forgot to give you the link http://technet.microsoft.com/en-us/library/aa996335.aspx
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Hi Thank you for the link.  But how do I get the script to look at the csv file for the information that needs to be imported?
0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
build your csv something like

Alias,Name,UPN,Password,email
User_One,User One,userone@yourUPNsuffix.com,P@ssw0rd1,userone@domain1.com
User_Two,User Two,usertwo@yourUPNsuffix.com,P@ssw0rd2,usertwo@domain2.com
User_Three,User Three,userthree@yourUPNsuffix.com,P@ssw0rd3,userthree@domain3.com

Import-CSV c:\list.csv | foreach {New-mailuser -Alias $_.alias -Name $_.name -UserPrincipalName $_.UPN -Password (ConvertTo-SecureString $_.password -AsPlainText -Force) -ExternalEmailAddress $_.email -OrganizationalUnit domain.com/users}
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Hi
Thank you for this information. In my .csv file I also have office telephone number, Mobile phone number, Company, Job Title and Manager.  Would you know how I could incorporate these at the same time?

On a slightly different scenario.
If the users already exist in Acive Directory (Server 2003). Could you mail enable them via a script and .csv file? If so how?

0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
No for the extra information it won't work with new-mailuser you will need to create a user using new-aduser


Import-CSV c:\list.csv | foreach {New-ADUser -Name $_.name -UserPrincipalName $_.UPN -Password (ConvertTo-SecureString $_.password -AsPlainText -Force) -OrganizationalUnit domain.com/users -OfficePhone $_.OfficePhone -Company $_.company -Manager $_.manager}

for all properties check http://technet.microsoft.com/en-us/library/ee617253.aspx

then run
Import-CSV c:\list.csv | foreach { Enable-Mailuser $_.UPN -Alias $_.Alias  -ExternalEmailAddress $_.email}


this last one will also apply to your second scenario so basically we created first enabled later


0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Hi

I have done a test import using just Alias,Name,UPN,Password,email which has worked well.

However Name obvioulsly gives me "Display Name" in Active Directory.  What parameters do I need to get Firstname and Lastname?

If anyone can also help on the other quetions I have above.as well I would appreciate it.

Kevan
0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
Check the link I gave you ! -GivenName  and -Surname


what other quesitons ?
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Hi Thank you.  I think my last question crossed with your response in the ether!!

Just giving it all a try now.
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Hi

I am getting the error below when trying to run the New-ADUser command.  I am running this on the Exchange 2010 sp1 server in the Exchange Management shell. We are still in a Windows 2003 domain.  What am I doing wrong?  Would this command only work if I was in a Windows 2008 Domain?

The term 'New-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:62
+ Import-csv "c:\wrcuserswithoutemail.csv"| foreach {New-ADUser <<<<  -GivenName $_.First -Surname $_.Lastname -alias $
_.alias -name $_.name -userPrincipalName $_.UPN -Org $_.organizationalunit -OfficePhone $_.OfficePhone  -MobilePhone $_
.Mobile -Company $_.company -Office $_.office -title $_.JobTitle -Password (ConvertTo-SecureString $_.Password -AsPlain
Text -Force) }
    + CategoryInfo          : ObjectNotFound: (New-ADUser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException



REgards

Kevan
0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
yea sorry you need to do an import-module activedirectory before
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
How do I do that?
0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
just from exchange management shell type

Import-Module ActiveDirectory
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Sorry- More problems.  I get the error message below when running Import-Module ActiveDirectory


[PS] C:\Windows\system32>import-module ActiveDirectory
WARNING: Error initializing default drive: 'Unable to find a default server with Active Directory Web Services
running.'.
[PS] C:\Windows\system32>
0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
you don't have any 2008R2 domain contorller ?
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
No.  I have said all along we are running a Windows 2003 Domain.
0
 
LVL 49

Accepted Solution

by:
Akhater earned 500 total points
Comment Utility
Sorry I missed that, we need then to revert to New-MailUser and we won't be able to add office/company etc...


Import-CSV c:\list.csv | foreach {New-mailuser -Alias $_.alias -Name $_.name -UserPrincipalName $_.UPN -Password (ConvertTo-SecureString $_.password -AsPlainText -Force) -ExternalEmailAddress $_.email -OrganizationalUnit domain.com/users}
0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
Alternatively you can use quest tools and user the New-QADUser http://wiki.powergui.org/index.php/New-QADUser
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Hi

I have imported the users using our AD Manager Plus to our Domain and then Mail Enabled them using

Import-CSV c:\list.csv | foreach { Enable-Mailuser $_.UPN -Alias $_.Alias  -ExternalEmailAddress $_.email}

from the Exchange Server.

Thank you very much for all your help.  Hopefully we will have a Windows 2008 R2 Domain soon so as we can fully utilize Power Shell.
0
 
LVL 1

Author Closing Comment

by:cmiadmin
Comment Utility
Thank you for all your help. I have learnt a lot.
0
 
LVL 49

Expert Comment

by:Akhater
Comment Utility
thank you for the point and sorry I wasn't of big help
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Hi

I thought I had got thie resolved.
I am trying to run this command to mail enable the users that I have already set up.

Import-csv "c:\wrcusersemail.csv"| foreach {Enable-mailuser -userPrincipalName $_.UPN -alias $_.Alias -ExternalEmailAddress $_.email}

However I get this error:

A positional parameter cannot be found that accepts argument 'SEdwards@oxford.nsf.org'.
    + CategoryInfo          : InvalidArgument: (:) [Enable-MailUser], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Enable-MailUser

Can you tell me why?

Thank you.
Kevan
0
 
LVL 1

Author Comment

by:cmiadmin
Comment Utility
Hi  I have sorted this out.

I used:

import-csv "c:\wrcusersemail.csv"| foreach {Enable-mailuser -Identity $_.Identity -alias $_.Alias -ExternalEmailAddress $_.email}

And created a field for -identity in my csv file.

For info for other users this looked like this

child.domain.org/OU/OU/Users name as below.
'uk.nss.org/london-Users/WRC/Alan Smith'
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
how to add IIS SMTP to handle application/Scanner relays into office 365.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now