Tuesday, March 22, 2016

Email Address Audit

Recently,​ a client asked for a list of all email addresses currently active on the server.
As anyone in IT can tell you, this would be a nightmarish task for any Medium to Enterprise company.
These two scripts will be your friend. They work in Exchange 2010, but I haven't tested them in 2007 or 2013.

Export Mailbox Email addresses and Alias.
Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Export-CSV c:\temp\smtp.csv -NoTypeInformation
The following will give you a useful list of Distribution groups, with all their members. This can be typed in, or copied to a .PS1 file, and ran as a script.
$saveto = "C:\temp\listmembers.txt"

Get-DistributionGroup | sort name | ForEach-Object {

 "`r`n$($_.Name)`r`n=============" | Add-Content $saveto
 Get-DistributionGroupMember $_ | sort Name | ForEach-Object {
  If($_.RecipientType -eq "UserMailbox")
    $_.Name + " (" + $_.PrimarySMTPAddress + ")" | Add-Content $saveto

No comments:

Post a Comment