neu script
This commit is contained in:
30
Scripts/powershell/get_daily_email_senders.ps1
Normal file
30
Scripts/powershell/get_daily_email_senders.ps1
Normal file
@@ -0,0 +1,30 @@
|
||||
# PowerShell script to list senders of emails from an on-premise Exchange server for the current day.
|
||||
|
||||
# Set the start and end times for today
|
||||
$today = Get-Date -Hour 0 -Minute 0 -Second 0
|
||||
$tomorrow = (Get-Date).AddDays(1).Date
|
||||
|
||||
Write-Host "Searching for emails sent between $($today) and $($tomorrow)..."
|
||||
|
||||
try {
|
||||
# Get message tracking logs for sent emails within today's date range
|
||||
# Filtering by EventID 'SEND' focuses on emails leaving the server or being sent internally.
|
||||
# Adjust -ResultSize as needed; 'Unlimited' retrieves all, but can be slow for large environments.
|
||||
$sentEmails = Get-MessageTrackingLog -Start $today -End $tomorrow -EventId "SEND" -ResultSize Unlimited |
|
||||
Select-Object -ExpandProperty Sender |
|
||||
Sort-Object -Unique
|
||||
|
||||
if ($sentEmails) {
|
||||
Write-Host "`nSenders of emails today:`n"
|
||||
$sentEmails | ForEach-Object {
|
||||
Write-Host $_
|
||||
}
|
||||
Write-Host "`nTotal unique senders: $($sentEmails.Count)"
|
||||
} else {
|
||||
Write-Host "`nNo emails sent today found."
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "An error occurred while retrieving message tracking logs: $($_.Exception.Message)"
|
||||
Write-Error "Please ensure you have the necessary Exchange management tools installed and are running the script with appropriate permissions."
|
||||
}
|
||||
2
youtube.md
Normal file
2
youtube.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# WoT
|
||||
https://www.youtube.com/watch?v=6kn3b5zZnwE
|
||||
Reference in New Issue
Block a user