# Initialize some variables used for counting and for output
$From = Get-Date "15/07/2014"
$To = $From.AddDays(1)
$TotalOutput = @()
[Int64] $intSent = $intRec = 0
[Int64] $intSentSize = $intRecSize = 0
[String] $strEmails = $null
Do
{
# Start building the variable that will hold the information for the day
$obj = new-object PSObject
$obj | add-member -membertype NoteProperty -name "DayOfWeek" -value $($From.DayOfWeek)
$obj | add-member -membertype NoteProperty -name "Date" -value $($From.ToShortDateString())
$intSent = $intRec = 0
(Get-TransportServer) | Get-MessageTrackingLog -ResultSize Unlimited -Start $From -End $To | ForEach {
# Sent E-mails
If ($_.EventId -eq "RECEIVE" -and $_.Source -eq "STOREDRIVER")
{
$intSent++
$intSentSize += $_.TotalBytes
}
# Received E-mails
If ($_.EventId -eq "DELIVER")
{
$intRec++
$intRecSize += $_.TotalBytes
}
}
$intSentSize = [Math]::Round($intSentSize/1KB, 0)
$intRecSize = [Math]::Round($intRecSize/1KB, 0)
# Add the numbers to the $strEmails variable and print the result for the day
$obj | add-member -membertype NoteProperty -name "Sent" -value $intSent
$obj | add-member -membertype NoteProperty -name "Sent Size (KB)" -value $intSentSize
$obj | add-member -membertype NoteProperty -name "Received" -value $intRec
$obj | add-member -membertype NoteProperty -name "Received Size (KB)" -value $intRecSize
$strEmails += "$intSent,$intSentSize,$intRec,$intRecSize"
$TotalOutput+=$obj
$obj=$null
# Increment the From and To by one day
$From = $From.AddDays(1)
$To = $From.AddDays(1)
}
#While ($To -lt (Get-Date))
While ($To -lt (Get-Date "17/07/2014"))
$TotalOutput | export-csv -path c:\PromedioCantidadMail.csv -NoTypeInformation
$From = Get-Date "15/07/2014"
$To = $From.AddDays(1)
$TotalOutput = @()
[Int64] $intSent = $intRec = 0
[Int64] $intSentSize = $intRecSize = 0
[String] $strEmails = $null
Do
{
# Start building the variable that will hold the information for the day
$obj = new-object PSObject
$obj | add-member -membertype NoteProperty -name "DayOfWeek" -value $($From.DayOfWeek)
$obj | add-member -membertype NoteProperty -name "Date" -value $($From.ToShortDateString())
$intSent = $intRec = 0
(Get-TransportServer) | Get-MessageTrackingLog -ResultSize Unlimited -Start $From -End $To | ForEach {
# Sent E-mails
If ($_.EventId -eq "RECEIVE" -and $_.Source -eq "STOREDRIVER")
{
$intSent++
$intSentSize += $_.TotalBytes
}
# Received E-mails
If ($_.EventId -eq "DELIVER")
{
$intRec++
$intRecSize += $_.TotalBytes
}
}
$intSentSize = [Math]::Round($intSentSize/1KB, 0)
$intRecSize = [Math]::Round($intRecSize/1KB, 0)
# Add the numbers to the $strEmails variable and print the result for the day
$obj | add-member -membertype NoteProperty -name "Sent" -value $intSent
$obj | add-member -membertype NoteProperty -name "Sent Size (KB)" -value $intSentSize
$obj | add-member -membertype NoteProperty -name "Received" -value $intRec
$obj | add-member -membertype NoteProperty -name "Received Size (KB)" -value $intRecSize
$strEmails += "$intSent,$intSentSize,$intRec,$intRecSize"
$TotalOutput+=$obj
$obj=$null
# Increment the From and To by one day
$From = $From.AddDays(1)
$To = $From.AddDays(1)
}
#While ($To -lt (Get-Date))
While ($To -lt (Get-Date "17/07/2014"))
$TotalOutput | export-csv -path c:\PromedioCantidadMail.csv -NoTypeInformation