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

x
?
Solved

powershell

Posted on 2011-03-16
2
Medium Priority
?
592 Views
Last Modified: 2012-05-11
Hi is there a script i can use to run a report on Exchange 2007 to see how many users have sent emails internal and external.
Need it for inbound and out bound

Thank you

0
Comment
Question by:happyexchange
2 Comments
 
LVL 12

Expert Comment

by:Julian123
ID: 35146270
There is no direct partial script that will do this, but there is a Microsoft tool called the profile analyzer that will examine a set of mailboxes until you average sizes, amount of sent data, etc. It does not sound like exactly what you want, but it is the closest thing that I believe exists.

http://technet.microsoft.com/en-us/library/bb508856(EXCHG.65).aspx
0
 
LVL 13

Accepted Solution

by:
soostibi earned 2000 total points
ID: 35157192
This is a little statistics from the message tracking logs. This works in a single-Exchange-server environment.
$mailboxes = @{}

$domains = Get-AcceptedDomain | ?{$_.domaintype -eq "authoritative"}| Select-Object -ExpandProperty domainname | Select-Object -ExpandProperty domain
Get-MessageTrackingLog -ResultSize unlimited |?{$_.recipients} |%{
    $status = "$($_.eventid)-$($_.source)"
    $senderdomain = $_.sender -replace "[^@]+@",""
    $line = $_
    switch($status){
        "receive-smtp" {
            if(!($mailboxes.($line.recipients[0]))){$mailboxes.($line.recipients[0]) = @{}}
            $mailboxes.($line.recipients[0]).ReceivedFromExternal += 1
        }
        "send-smtp" {
            if(!($mailboxes.($line.sender))){$mailboxes.($line.sender) = @{}}
            $mailboxes.($line.sender).SentToExternal += 1
        }
        "deliver-storedriver" {
            if($domains -contains $senderdomain){
                if(!($mailboxes.($line.sender))){$mailboxes.($line.sender) = @{}}
                $mailboxes.($line.sender).SentToInternal += 1            
                $line.recipients | %{
                    if(!($mailboxes.$_)){$mailboxes.$_ = @{}}
                    $mailboxes.$_.ReceivedFromInternal += 1
                }
            }
        }
    }
}
$mailboxes.keys | %{
    New-Object -TypeName psobject -Property @{
        mailbox = $_
        ReceivedFromExternal = $mailboxes.$_.ReceivedFromExternal
        SentToExternal = $mailboxes.$_.SentToExternal
        SentToInternal = $mailboxes.$_.SentToInternal 
        ReceivedFromInternal = $mailboxes.$_.ReceivedFromInternal 
    }
} | ft mailbox, ReceivedFromExternal, ReceivedFromInternal, SentToExternal, ReceivedFromInternal

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
Stellar Exchange Toolkit: this 5 in 1 toolkit comes loaded with mega-software tool. Here’s an introduction to tools’ usage and advantages:
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…

885 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