Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Exchange 2010 create mail enabled users from a csv file

Posted on 2011-09-12
23
2,074 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
ID: 36523891
you would be looking for new-mailuser
0
 
LVL 49

Expert Comment

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

Author Comment

by:cmiadmin
ID: 36524051
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
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.

 
LVL 49

Expert Comment

by:Akhater
ID: 36524102
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
ID: 36528517
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
ID: 36528602
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
ID: 36528768
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
ID: 36528777
Check the link I gave you ! -GivenName  and -Surname


what other quesitons ?
0
 
LVL 1

Author Comment

by:cmiadmin
ID: 36534851
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
ID: 36534880
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
ID: 36534895
yea sorry you need to do an import-module activedirectory before
0
 
LVL 1

Author Comment

by:cmiadmin
ID: 36534906
How do I do that?
0
 
LVL 49

Expert Comment

by:Akhater
ID: 36534914
just from exchange management shell type

Import-Module ActiveDirectory
0
 
LVL 1

Author Comment

by:cmiadmin
ID: 36534927
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
ID: 36534959
you don't have any 2008R2 domain contorller ?
0
 
LVL 1

Author Comment

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

Accepted Solution

by:
Akhater earned 500 total points
ID: 36535072
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
ID: 36535139
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
ID: 36542624
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
ID: 36542638
Thank you for all your help. I have learnt a lot.
0
 
LVL 49

Expert Comment

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

Author Comment

by:cmiadmin
ID: 36544219
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
ID: 36544462
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
how to add IIS SMTP to handle application/Scanner relays into office 365.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 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