New-HistoricalSearch.ps1
something exciting
Some information about the exciting thing
Table of contents generated with markdown-toc
Script
.\PowerShellScripts\CapitalSupport\Functions\Connect-Office365Services.ps1
Connect-ExchangeOnline -Credential (Get-Credential)
Connect-MsolService -Credential (Get-Credential)
$emailDomains = Get-MsolDomain | Where-Object { $_.Status -eq 'Verified' }
foreach ($emailDomain in $emailDomains) {
Start-HistoricalSearch -ReportTitle ($emailDomain.Name + ' - ' + (Get-Date).AddDays(-10).ToShortDateString()) -StartDate "5/13/2019 00:00:00" -EndDate "5/13/2019 23:30:00" -Direction Sent -ReportType MessageTraceDetail -SenderAddress ('*@' + $emailDomain.Name) -NotifyAddress '[email protected]'
Start-HistoricalSearch -ReportTitle ($emailDomain.Name + ' - ' + (Get-Date).AddDays(-9).ToShortDateString()) -StartDate "5/14/2019 00:00:00" -EndDate "5/14/2019 23:30:00" -Direction Sent -ReportType MessageTraceDetail -SenderAddress ('*@' + $emailDomain.Name) -NotifyAddress '[email protected]'
Start-HistoricalSearch -ReportTitle ($emailDomain.Name + ' - ' + (Get-Date).AddDays(-8).ToShortDateString()) -StartDate "5/15/2019 00:00:00" -EndDate "5/15/2019 23:30:00" -Direction Sent -ReportType MessageTraceDetail -SenderAddress ('*@' + $emailDomain.Name) -NotifyAddress '[email protected]'
Start-HistoricalSearch -ReportTitle ($emailDomain.Name + ' - ' + (Get-Date).AddDays(-7).ToShortDateString()) -StartDate "5/16/2019 00:00:00" -EndDate "5/16/2019 23:30:00" -Direction Sent -ReportType MessageTraceDetail -SenderAddress ('*@' + $emailDomain.Name) -NotifyAddress '[email protected]'
Start-HistoricalSearch -ReportTitle ($emailDomain.Name + ' - ' + (Get-Date).AddDays(-6).ToShortDateString()) -StartDate "5/17/2019 00:00:00" -EndDate "5/17/2019 23:30:00" -Direction Sent -ReportType MessageTraceDetail -SenderAddress ('*@' + $emailDomain.Name) -NotifyAddress '[email protected]'
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.