Audit emails sent using SendAs

Audit emails sent using SendAs
This commit is contained in:
AdminDroid 2023-09-26 19:51:51 +05:30
parent 8e83e5e12a
commit afbaefe360

View File

@ -1,4 +1,24 @@
 <#
=============================================================================================
Name: Audit Senas emails
Description: This script monitors emails that sent using SendAs permission
Version: 1.0
Website: o365reports.com
Script Highlights:
~~~~~~~~~~~~~~~~~~
1.The script uses modern authentication to retrieve audit logs.
2.The script can be executed with MFA enabled account too.
3.Exports report results to CSV file.
4.Helps to find out who sent email from a shared mailbox.
5.Allows you to generate send as email audit report for a custom period.
6.Automatically installs the EXO V2 module (if not installed already) upon your confirmation.
7.The script is scheduler-friendly. i.e., Credential can be passed as a parameter instead of saving inside the script.
For detailed script execution: https://o365reports.com/2022/03/30/audit-send-as-emails-in-microsoft-365-using-powershell
============================================================================================
#>
Param Param
( (
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
@ -208,28 +228,22 @@ If($OutputEvents -eq 0)
} }
else else
{ {
Write-Host `nThe output file contains $OutputEvents audit records Write-Host `nThe output file contains $OutputEvents audit records `n
Write-Host `nFor more Office 365 related PowerShell scripts, visit: https://o365reports.com -ForegroundColor Cyan
if((Test-Path -Path $OutputCSV) -eq "True") if((Test-Path -Path $OutputCSV) -eq "True")
{ {
Write-Host `nThe Output file availble in $OutputCSV -ForegroundColor Green Write-Host " The Output file availble in:" -NoNewline -ForegroundColor Yellow
Write-Host $OutputCSV
$Prompt = New-Object -ComObject wscript.shell $Prompt = New-Object -ComObject wscript.shell
$UserInput = $Prompt.popup("Do you want to open output file?",` $UserInput = $Prompt.popup("Do you want to open output file?",`
0,"Open Output File",4) 0,"Open Output File",4)
If ($UserInput -eq 6) If ($UserInput -eq 6)
{ {
Invoke-Item "$OutputCSV" Invoke-Item "$OutputCSV"
} }
} }
} }
#Disconnect Exchange Online session #Disconnect Exchange Online session
Disconnect-ExchangeOnline -Confirm:$false -InformationAction Ignore -ErrorAction SilentlyContinue Disconnect-ExchangeOnline -Confirm:$false -InformationAction Ignore -ErrorAction SilentlyContinue
Write-Host `n~~ Script prepared by AdminDroid Community ~~`n -ForegroundColor Green
<# Write-Host "~~ Check out " -NoNewline -ForegroundColor Green; Write-Host "admindroid.com" -ForegroundColor Yellow -NoNewline; Write-Host " to get access to 1800+ Microsoft 365 reports. ~~" -ForegroundColor Green `n`n
============================================================================================
Description: This script monitors emails that sent using SendAs permission
Website: o365reports.com
For detailed script execution: https://o365reports.com/2022/03/30/audit-send-as-emails-in-microsoft-365-using-powershell
============================================================================================
#>