Link to home
Start Free TrialLog in
Avatar of cmiadmin
cmiadminFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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.

 
Avatar of Akhater
Akhater
Flag of Lebanon image

you would be looking for new-mailuser
Avatar of cmiadmin

ASKER

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?
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}
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?

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


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


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

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

Import-Module ActiveDirectory
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>
you don't have any 2008R2 domain contorller ?
No.  I have said all along we are running a Windows 2003 Domain.
ASKER CERTIFIED SOLUTION
Avatar of Akhater
Akhater
Flag of Lebanon image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Alternatively you can use quest tools and user the New-QADUser http://wiki.powergui.org/index.php/New-QADUser
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.
Thank you for all your help. I have learnt a lot.
thank you for the point and sorry I wasn't of big help
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
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'