*companyname.
Hello, I have some user with PrimarySmtpAddress = user@companyname1.com and I need then to change all user having the @companyname1.com to @companyname.com as a PrimarySmtpAddress. I thought about getting all user with @companyname1.com but I don't know hw to get what is befor the @ like *@companyname1.com I tried this: Get-Mailbox -ResultSize Unlimited | Where {$_.PrimarySmtpAddress -like "*@companyname1.com"} And wanted to add after the above command : | Set-MailContact -PrimarySmtpAddress -like "*@companyname.com"} But I am not doing the right things.. Could you please help me out??
December 9th, 2009 2:29pm

Filtering the contacts with Companyname1.com is fine but this is not correct method to change primary SMTP Address. i would suggest you check Recipient policy and check if it enabled on these contacts. most likely it would have happened because recipient policy would not be enabled on these contacts. you can find this out by below commands. Get-Mailbox -ResultSize Unlimited | Where {$_.emailaddresspolicyenabled -eq $false} | ft Name, Displayname, PrimarySMTPaddress, Externalemailaddress Let us know what comes up. Thanks.Vishal Ramnani | MCITP - Exchange 2007 | MCSE Messaging | MCTS - Win 2008 Config
Free Windows Admin Tool Kit Click here and download it now
December 9th, 2009 2:51pm

Hi,Here is a simple script that sets new Primary SMTP-addresses for existing users from a csv file$file = $Args[0]clswrite-host 'This script sets primarySMTP-address on a mailbox inExchange'-foregroundcolor "yellow"write-host 'File to be imported: ' $file -foregroundcolor "yellow"write-host $file$Csv = Import-Csv $file$Csv | ForEach-Object -Process {set-Mailbox -identity $_.TargetAddress-EmailAddressPolicyEnabled $false -Primarysmtpaddress $_.targetAddress}regards from www.windowsadmin.infoManuPhilip
December 9th, 2009 2:55pm

Could you please, provide me further detail/assistance to proceed? It is a very usefull! Thanks
Free Windows Admin Tool Kit Click here and download it now
December 9th, 2009 3:10pm

Hi,Do you mean you just want to change some users' primary mail address?If yes, I would like to create another email address policy including these users. How to Create an E-Mail Address Policyhttp://technet.microsoft.com/en-us/library/bb124401(EXCHG.80).aspxAnd be sure mail address policy of the users whether enabled or not as Vishal said before create the policy.Frank Wang
December 10th, 2009 6:18am

Yes, some users have user@companyname1.com and others and have @companyname.com For Example> user1 has: Primary smtp address -- user1@companyname1.com and "Secondary" smtp address -- user1@companyname.com I would like user 1 to get @companyname.com as Primary smtp address instead of companyname1.com so I just wanna change the Primary smtp addres from the smtp addresses I already have. Please do not hesiate to get back to me if u need further information. Graig
Free Windows Admin Tool Kit Click here and download it now
December 10th, 2009 11:45am

Can you check one contact and verify the attribute EmailAddressPolicyEnabled is True or false? Get-Mailbox -id <contact ID> | fl emailaddresspolicy* If False, can you try enabling it? and check if this change your Primary SMTP Address. Get-Mailbox -id <Contact ID> | Set-Mailbox -Emailaddresspolicyenabled:$True Thanks. Vishal Ramnani | MCITP - Exchange 2007 | MCSE Messaging | MCTS - Win 2008 Config
December 10th, 2009 11:56am

Get-Mailuser -ResultSize Unlimited | Where {$_.emailaddresspolicyenabled -like "false"} And I got no result because I already set all mailuser withe the -Emailaddresspolicyenabled:$True I just notice that some users have the "wrong " primary SMTP address. I thought it was possible to set the primary address Get-Mailuser -ResultSize Unlimited | where {$_.PrimarySmtpAddress -like "@companyname1.com"} | Set-Mailuser {$_.PrimarySmtpAddress -like "@companyname.com"} ... or something like that :S Thanks
Free Windows Admin Tool Kit Click here and download it now
December 10th, 2009 12:46pm

OK. In that case try below. Get-Mailuser -ResultSize Unlimited | get-MailUser | where {$_.PrimarySmtpAddress -like "*@companyname1.com"} | foreach { $current = $_ $indexof = $current.emailaddresses.indexof($($current.emailaddresses | where {$_.addressstring -like "*@companyname.com"}).proxyaddressstring) $index = $current.emailaddresses.indexof($indexof) $current.emailaddresses.makeprimary($index) Set-MailUser -Identity $_ -EmailAddresses $current.emailaddresses -EmailAddressPolicyEnabled:$false Set-MailUser -Identity $_ -EmailAddressPolicyEnabled:$true $id = $_.displayname Get-MailUser -Identity $id } I am assuming that all objects already have your desired smtp address space in EmailAddresses attribute but in affected object it is not set as primary. The code will enumerate all contacts where the primary SMTP address matches the condition and then find the SMTP address in "Emailaddresses" attribute with desired domain name and then Make that one primary. Let me know if any question. Thanks. Vishal Ramnani | MCITP - Exchange 2007 | MCSE Messaging | MCTS - Win 2008 Config
December 10th, 2009 1:21pm

Hi, Did that help? Thanks. Vishal Ramnani MCITP - Exchange 2007, MCSE Messaging, MCTS - Win 2008 Config
Free Windows Admin Tool Kit Click here and download it now
December 11th, 2009 12:20pm

Hey Vishal, Sorry for not getting back to you sooner. I need to run the test on my lab but don't have access a he moment. As soon as I test it I will get back to you. Thanks, G
December 11th, 2009 1:36pm

Hello Vishal,Sorry for the delay... It did work but had to add * before the @. E.g: "@companyname1.com" should read "*@companyname1.com"The set-mailuser command replace all the SMTP addresses. Any way to have an add in the smpt addresses. (no replacement) ??Thanks,Graig
Free Windows Admin Tool Kit Click here and download it now
December 14th, 2009 5:06pm

Yes! there suppose to be a * to include all (wildcard). its a typo. i will correct that. Can you explain your second statement in detail. The script should find that SMTP address with @company.com smtp address space and make that one as primary (NO Replacement or addition). its not suppose to replace it. Do you mean to say that those mail users does not have @company.com smtp address in EmailAddresses attribute at all? if the @company.com smtp address is not there then above script will may not work. As i said earlier, i assuming that affected mail user accounts have @company1.com smtp address as primary and they also have @company.com smtp address as NON-Primary in EmailAddresses attribute array. Vishal Ramnani MCITP - Exchange 2007, MCSE Messaging, MCTS - Win 2008 Config
December 14th, 2009 6:00pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics