Identify Emails Received From External Domains

This commit is contained in:
AdminDroid 2025-06-09 10:30:53 +05:30
parent 53a24435a7
commit 9394cba317

View File

@ -1,14 +1,14 @@
<# <#
============================================================================================= =============================================================================================
Name: Trace Inbound External Emails in Exchange Online Name: Trace Inbound External Emails in Exchange Online
Version: 1.0 Version: 1.1
Website: o365reports.com Website: o365reports.com
Script Highlights: Script Highlights:
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
1. Exports emails received from external domains into a CSV file. 1. Exports emails received from external domains into a CSV file.
2. Supports exporting emails within a specified 30-day time range. 2. Supports exporting emails within a specified 90-day time range.
3. Lists emails received from a specific external domain. 3. Lists emails received from a specific external domain.
4. Finds emails received from a specific external user. 4. Finds emails received from a specific external user.
5. Audit emails received by a specific user from external domains. 5. Audit emails received by a specific user from external domains.
@ -20,6 +20,11 @@ Script Highlights:
For detailed Script execution: https://o365reports.com/2025/06/03/trace-emails-received-from-external-domains-in-exchange-online For detailed Script execution: https://o365reports.com/2025/06/03/trace-emails-received-from-external-domains-in-exchange-online
Change Log
~~~~~~~~~~
V1.0 (Jun 03, 2025) - File created
V1.1 (Jun 09, 2025) - Extended message tracing period from 30 to 90 days.
============================================================================================ ============================================================================================
#> #>
@ -41,7 +46,7 @@ param(
) )
#--------------------------------------------------- Date Time Checking --------------------------------------------------- #--------------------------------------------------- Date Time Checking ---------------------------------------------------
$MaxStartDate = ((Get-Date).AddDays(-30)).Date $MaxStartDate = ((Get-Date).AddDays(-90)).Date
if (-not $StartDate -and -not $EndDate) { if (-not $StartDate -and -not $EndDate) {
$EndDate = (Get-Date).Date $EndDate = (Get-Date).Date
@ -53,7 +58,7 @@ try {
if ($EndDate) { $EndDate = [DateTime]$EndDate } if ($EndDate) { $EndDate = [DateTime]$EndDate }
if ($StartDate -lt $MaxStartDate) { if ($StartDate -lt $MaxStartDate) {
Write-Host "Error: MessageTrace can only be retrieved for the past 30 days. Select a date after $MaxStartDate" -ForegroundColor Red Write-Host "Error: MessageTrace can only be retrieved for the past 90 days. Select a date after $MaxStartDate" -ForegroundColor Red
Exit Exit
} }
if ($EndDate -lt $StartDate) { if ($EndDate -lt $StartDate) {