Solved

Showing mailbox with different email domain alias

Posted on 2013-01-27
4
416 Views
Last Modified: 2013-04-15
Hi People,

Can anyone please assist me with the powershell script to display the mailbox with additional alias or different authoritative domain ?

I got a script here from one of the Experts-Exchange author jjmck:

$domain = ""
Get-Mailbox -ResultSize unlimited | % {
	foreach ($address in $_.emailaddresses) {
		If (($address.type -eq "SMTP") -and (($address.Address.Split("@")[1] -eq $domain))) {
			$_.emailaddresses -= [Microsoft.Exchange.Data.ProxyAddress]("smtp:$($address.address)")
		}
	}
	Set-Mailbox $_.primarysmtpaddress -EmailAddresses $_.EmailAddresses
}

Open in new window


the script above was to change any email address that has different authoritative domain. what I need is to know how many records first then do the changes so that my manager know how many mailboxes affected.

so if anyone please can assist me in modifying those script above that'd be greatly appreciated.

Thanks
0
Comment
  • 3
4 Comments
 
LVL 37

Accepted Solution

by:
Jamie McKillop earned 500 total points
ID: 38827543
Hello,

If you just want a count, this will do what you want:

$domain = ""
$i=0
Get-Mailbox -ResultSize unlimited | % {
	$j=0
	foreach ($address in $_.emailaddresses) {
		If (($address.type -eq "SMTP") -and (($address.Address.Split("@")[1] -eq $domain))) {
			#$_.emailaddresses -= [Microsoft.Exchange.Data.ProxyAddress]("smtp:$($address.address)")
			$j++
		}
	}
	if ($j -ne 0) {$i++}
	#Set-Mailbox $_.primarysmtpaddress -EmailAddresses $_.EmailAddresses
} 
$i

Open in new window


JJ
0
 
LVL 7

Author Comment

by:Senior IT System Engineer
ID: 38829071
thanks JJ,

I haven't tried that script yet as it is still on my way to the office. hopfully it should also displays the mailboxes with different mail domain as well.
0
 
LVL 7

Author Comment

by:Senior IT System Engineer
ID: 38829830
JJ, why it only shows the number 0 as the result ?
I have changed the $domain = "mydomain.com"
0
 
LVL 7

Author Closing Comment

by:Senior IT System Engineer
ID: 39082781
Thanks !
0

Featured Post

Integrate social media with email signatures

Is your company active on social media? Do you also use email signatures? Including social media icons in your email signature is a great way to get fans for free. Let all your email users know you’re on social media quickly and easily, in a single click.

Question has a verified solution.

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

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Read this checklist to learn more about the 15 things you should never include in an email signature.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now