Solved

Add Additional Aliases for one mailbox via CSV import

Posted on 2014-10-08
12
654 Views
Last Modified: 2014-10-20
Hello,

I have an account called 'websitepayments' I need to add loads of additional alias' to this mailbox only, I've attached an excel document, how would I go about this?

Thanks in advance!
MobilePaymentSMTPList.xlsx
0
Comment
Question by:ProjNet
  • 7
  • 5
12 Comments
 
LVL 19

Expert Comment

by:Miguel Angel Perez Muñoz
ID: 40368122
This account has any alias now?
0
 

Author Comment

by:ProjNet
ID: 40368140
Hi Miquel,

Yes it has, but none of the alias that are in the document.

Thanks
0
 
LVL 19

Expert Comment

by:Miguel Angel Perez Muñoz
ID: 40368159
Ok, I know one way maybe someone would get you some more elegant (one command):
First run:
Get-Mailbox websitepayments | select emailaddresses
This gives you all smtp address this mailbox, copy to a text file on a email per line, only email, no smtp or whatever.
Then, on this txt file, add all smpt address included on your excel.
Must be one email per line.
The last command:
Set-Mailbox websitepayment -EmailAddresses (get-content file_with_emails.txt)
Read all emails on file and replace all email address of websitepayment with readed email on file.

I suggest you check first on another test account.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:ProjNet
ID: 40377460
Hello,

I tried your command but the shell cuts off the addresses? like so:


EmailAddresses                                                                
--------------                                                                
{SMTP:website.payments@wyevalegardencentres.co.uk, smtp:Website.Payments@the...
0
 
LVL 19

Expert Comment

by:Miguel Angel Perez Muñoz
ID: 40379267
Yes you must do some changes, maybe do a redirect to txt file:
Get-Mailbox websitepayments | select emailaddresses |  out-file C:\file.txt
Edit this txt to remove all "smtp:" and whatever not an email address (very easy with search and replace) and add to this file all email address you want to add. Then run Set-Mailbox websitepayment -EmailAddresses (get-content file_with_emails.txt)
0
 

Author Comment

by:ProjNet
ID: 40379435
Hi Miguel,

Tried the above didn't quite work out for me, I also tried this command:

Import-CSV "c:\documents and settings\adurrant\desktop\addemailaddresses.csv" | Set-Mailbox -Identity WebsitePayments -EmailAddresses @{add=$_.NewEmailAddress}}

I moved all of the email addresses into one column, I got this error:


[PS] C:\Documents and Settings\adurrant>Import-CSV "c:\documents and settings\adurrant\desktop\addemailaddresses.csv" |
Set-Mailbox -Identity WebsitePayments -EmailAddresses @{add=$_.NewEmailAddress}
Set-Mailbox : Cannot bind parameter 'EmailAddresses'. Cannot convert the "System.Collections.Hashtable" value of type "
System.Collections.Hashtable" to type "Microsoft.Exchange.Data.ProxyAddress".
At line:1 char:134
+ Import-CSV "c:\documents and settings\adurrant\desktop\addemailaddresses.csv" | Set-Mailbox -Identity WebsitePayments
 -EmailAddresses <<<<  @{add=$_.NewEmailAddress}
    + CategoryInfo          : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.RecipientTasks.SetMailbox


Any ideas?
0
 
LVL 19

Expert Comment

by:Miguel Angel Perez Muñoz
ID: 40379448
This is caused by datatype. Could you paste result of:
Import-CSV "c:\documents and settings\adurrant\desktop\addemailaddresses.csv" |gm

Thanks.
0
 

Author Comment

by:ProjNet
ID: 40379827
Hello,

Results:

[PS] C:\Documents and Settings\adurrant>Import-CSV "c:\documents and settings\adurrant\desktop\addemailaddresses.csv" |g
m


   TypeName: System.Management.Automation.PSCustomObject

Name            MemberType   Definition
----            ----------   ----------
Equals          Method       bool Equals(System.Object obj)
GetHashCode     Method       int GetHashCode()
GetType         Method       type GetType()
ToString        Method       string ToString()
NewEmailAddress NoteProperty System.String NewEmailAddress=MobilePayment.175@wgcl.co.uk
0
 
LVL 19

Expert Comment

by:Miguel Angel Perez Muñoz
ID: 40379845
Try this:
Set-Mailbox -Identity WebsitePayments -EmailAddresses @{add=import-csv "c:\documents and settings\adurrant\desktop\addemailaddresses.csv"}}

But txt command must work.
0
 

Author Comment

by:ProjNet
ID: 40380045
Thanks again,

still errored:

[PS] C:\Documents and Settings\adurrant>Set-Mailbox -Identity WebsitePayments -EmailAddresses @{add=import-csv "c:\docum
ents and settings\adurrant\desktop\addemailaddresses.csv"}}
Unexpected token '}' in expression or statement.
At line:1 char:140
+ Set-Mailbox -Identity WebsitePayments -EmailAddresses @{add=import-csv "c:\documents and settings\adurrant\desktop\ad
demailaddresses.csv"}} <<<<
    + CategoryInfo          : ParserError: (}:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

[PS] C:\Documents and Settings\adurrant>Set-Mailbox -Identity WebsitePayments -EmailAddresses @{add=import-csv "c:\docum
ents and settings\adurrant\desktop\addemailaddresses.csv"}
Set-Mailbox : Cannot bind parameter 'EmailAddresses'. Cannot convert the "System.Collections.Hashtable" value of type "
System.Collections.Hashtable" to type "Microsoft.Exchange.Data.ProxyAddress".
At line:1 char:54
+ Set-Mailbox -Identity WebsitePayments -EmailAddresses <<<<  @{add=import-csv "c:\documents and settings\adurrant\desk
top\addemailaddresses.csv"}
    + CategoryInfo          : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.RecipientTasks.SetMailbox
0
 

Accepted Solution

by:
ProjNet earned 0 total points
ID: 40382049
I managed to do this via ADDS module instead, example:

set-aduser websitepayments -Add @{proxyAddresses="smtp:MobilePayment.175@wgcl.co.uk"}
0
 

Author Closing Comment

by:ProjNet
ID: 40391537
worked it out myself, thanks to miquel though :)
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
This article runs through the process of deploying a single EXE application selectively to a group of user.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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