A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
Hi,@mark terry
Thanks for posting your question in the Microsoft Q&A forum.
First of all Exchange online forum doesn't support scripting, I hope you can understand that.
The following script is for reference only:
Please note that you will need the appropriate permissions to run this script and it assumes you have the Exchange Online PowerShell module installed and are connected to your Exchange Online session.
# Define the path to the CSV file
$csvFilePath = "C:\Users\Documents\test.csv"
$mailContacts = import-csv -path $csvFilePath
foreach ($mailContact in $mailContacts) {
# Try to get the MailContact from Exchange Online
$onlineMailContact = Get-MailContact -Identity $mailContact.PrimarySMTPAddress -ErrorAction SilentlyContinue
# Check if the MailContact exists in Exchange Online
if ($onlineMailContact) {
Write-Host "MailContact $($mailContact.PrimarySMTPAddress) still exists in Exchange Online."
} else {
Write-Host "MailContact $($mailContact.PrimarySMTPAddress) has been deleted from Exchange Online."
}
}
Write-Host "All MailContacts have been checked."
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.