Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Showing mailbox with different email domain alias

Posted on 2013-01-27
4
Medium Priority
?
425 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 2000 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 8

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 8

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 8

Author Closing Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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…

926 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