Exchange 2010 create mail enabled users from a csv file

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.

 
LVL 1
cmiadminAsked:
Who is Participating?
 
AkhaterCommented:
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
 
AkhaterCommented:
you would be looking for new-mailuser
0
 
AkhaterCommented:
sorry i forgot to give you the link http://technet.microsoft.com/en-us/library/aa996335.aspx
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
cmiadminAuthor Commented:
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
 
AkhaterCommented:
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
 
cmiadminAuthor Commented:
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
 
AkhaterCommented:
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
 
cmiadminAuthor Commented:
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
 
AkhaterCommented:
Check the link I gave you ! -GivenName  and -Surname


what other quesitons ?
0
 
cmiadminAuthor Commented:
Hi Thank you.  I think my last question crossed with your response in the ether!!

Just giving it all a try now.
0
 
cmiadminAuthor Commented:
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
 
AkhaterCommented:
yea sorry you need to do an import-module activedirectory before
0
 
cmiadminAuthor Commented:
How do I do that?
0
 
AkhaterCommented:
just from exchange management shell type

Import-Module ActiveDirectory
0
 
cmiadminAuthor Commented:
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
 
AkhaterCommented:
you don't have any 2008R2 domain contorller ?
0
 
cmiadminAuthor Commented:
No.  I have said all along we are running a Windows 2003 Domain.
0
 
AkhaterCommented:
Alternatively you can use quest tools and user the New-QADUser http://wiki.powergui.org/index.php/New-QADUser
0
 
cmiadminAuthor Commented:
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
 
cmiadminAuthor Commented:
Thank you for all your help. I have learnt a lot.
0
 
AkhaterCommented:
thank you for the point and sorry I wasn't of big help
0
 
cmiadminAuthor Commented:
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
 
cmiadminAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.