Link to home
Start Free TrialLog in
Avatar of Michael Leonard
Michael LeonardFlag for United States of America

asked on

need assistance with a quest cmdlets script to add in a secondary alias

is there a way to add in a secondary email address to a group of 100 accounts in a particular OU based on an input file using the quest ad cmdlets?

so for example:
the primary email address for these 3 are:
bob.smith@xyz.com
john.smith@xyz.com
joe.brown@xyz.com

and i want to add in a secondary alias to each like:
bsmith@sym.com
jsmith@sym.com
jbrown@sym.com

thx in advance!

S.
Avatar of SubSun
SubSun
Flag of India image

Try this..
Import-Csv Test.csv | % {
$user = Get-Mailbox $_.SMTP 
$user.emailAddresses += $_.newsmtp
Set-Mailbox $user -emailAddresses $user.emailAddresses
}

Open in new window

Sample CSV file format..
SMTP,newsmtp
bob.smith@xyz.com,bsmith@sym.com
john.smith@xyz.com,jsmith@sym.com
joe.brown@xyz.com,jbrown@sym.com

Open in new window

Avatar of Michael Leonard

ASKER

hi Subsun, using your logic would we have to capture the full proxyAddresses string first for each user?
was hoping to avoid this and just add in the new additional smtp address. is that possible?
The script will collect emailAddresses of user then add the new one in to the list and then set it to user mailbox..
Ok thx Subsun. I will test in the lab today to validate. can i also add in an x500 address using this logic?
Yes.. try with
$user.emailAddresses += "X500:$($_.newsmtp)"
thx Subsun. the additional smtp +add script works perfect! thx much!

the X500 test failed w/this error:

Exception setting "EmailAddresses": "Cannot convert value "System.Object[]" to type "Microsoft.Exchange.Data.ProxyAddre
ssCollection". Error: "The address '/o=Accentus/ou=First Administrative Group/cn=Recipients/cn=2010test-123' is invalid
: "/o=myorg/ou=First Administrative Group/cn=Recipients/cn=2010test-123" isn't a valid SMTP address. The domain name
 can't contain spaces and it has to have a prefix and a suffix, such as example.com.""

here is how i have the script:

Import-Csv Test.csv | % {
$user = Get-Mailbox $_.SMTP
$user.emailAddresses += "X500:$($_.newsmtp)"
Set-Mailbox $user -emailAddresses $user.emailAddresses
}
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India 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
fantastic subsun. many thanks!

S.