Connect-ExchangeOnline
$SenderEmails = @("user1@acmecorp.com")
$StartDate = (Get-Date).AddDays(-10).Date
$EndDate = Get-Date
$finalReport = foreach ($Email in $SenderEmails) {
$userTraces = Get-MessageTraceV2 -SenderAddress $Email -StartDate $StartDate -EndDate $EndDate -ResultSize 5000
$uniqueEmails = $userTraces | Group-Object MessageId | ForEach-Object {
$firstEntry = $_.Group[0]
[PSCustomObject]@{
SenderAddress = $firstEntry.SenderAddress
# Keep as [datetime] object for proper sorting
Date = $firstEntry.Received.Date
}
}
$uniqueEmails | Group-Object Date | ForEach-Object {
[PSCustomObject]@{
SenderAddress = $Email
Date = [datetime]$_.Name
SentCount = $_.Count
}
}
}
$finalReport | Sort-Object Date, SenderAddress | Out-GridViewWas this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article