Powershell Exchange Message Per Day Sent and Reveive
Powershell Exchange Message Per Day Sent and Reveive# Initialize some variables used for counting and for output
Get-Date -UFormat "%Y-%m-%d-%H-%M" >>Per-day_recive.txt
$Account="wendychen"
$intSent = $intRec = 0
$intSentSize = $intRecSize = 0
$strEmails = $null
$times=Import-CSV "d:\LOGTime.csv"
foreach ($time in $times)
{
# Start building the variable that will hold the information for the day
$starttime=$time.starttime
$endtime=$time.endtime
echo $starttime $endtime ssss
$intSent = $intRec = 0
(Get-TransportServer -Identity wendy-*) | Get-MessageTrackingLog -ResultSize Unlimited -Recipients "$Account" -Start "$starttime" -End "$endtime" | ForEach {
# Sent E-mail
If ($_.EventId -eq "RECEIVE" -and $_.Source -eq "STOREDRIVER")
{
$intSent++
$intSentSize += $_.TotalBytes
}
# Received E-mails
If ($_.EventId -eq "DELIVER")
{
$intRec++
$intRecSize += $_.TotalBytes
}
}
$intSentSize = ::Round($intSentSize/1MB, 0)
$intRecSize = ::Round($intRecSize/1MB, 0)
$DataBase = Get-Mailbox -Identity $Account |Get-MailboxStatistics
Write-Host "$Account,`nintSentSize=$intSentSize,`nReciveSize=$intRecSize" -ForegroundColor Yellow
$DataBase.DisplayName,$DataBase.DataBaseName,$starttime,$endtime,$intRecSize,$intSentSize -join ";">>d:\"$Account"-Per-day_recive.csv
}
页:
[1]