command to list who sent emails from a shared mailbox for a specific date

7 Spice ups

We’re happy to help but not a script-writing service.

What have you tried? Where are you stuck?

If you post code, please use the ‘Insert Code’ button. Please and thank you!

192033ab-bb8f-4032-88a5-8e2313af0344-codebutton_small.png

  • Neally Bot
1 Spice up

Have not written any code and was looking for an out of the box command for anything SendAs… but if there is no commands for this, I guess I’m out of luck!

1 Spice up

You need to enable the mailbox audit for the shared mailbox before you search it*.* However, this will not work for past e-mail, only going forward once Auditing is turned on.

Enable audit log for a mailbox:

Set-Mailbox -Identity “sharedmailbox” -AuditEnabled $true

Then run below commands to see the details about somebody uses the shared mailbox to send out emails. Choose one of them. Both of them is work.

Search-MailboxAuditLog -Identity “SHARED1” -ShowDetails | Where {$_.Operation -eq “SendAs”} | Format-Table Operation, OperationResult, LogonUserDisplayName, ItemSubject, LastAccessed –Auto

Search-MailboxAuditLog -Identity “shared1” -LogonTypes Delegate -StartDate 7/20/2022 -EndDate 7/27/2022 -ShowDetails | Export-CSV -Path C:\Users\Administrator.CONTOSO\Documents\Scripts\shared.csv

Run below command

Get-Mailbox –ResultSize unlimited | Search-Mailbox -SearchQuery {sent:7/1/2022…7/20/2022 AND from:user2@contoso.com}-TargetMailbox ‘administrator@contoso.com’ -TargetFolder Inbox -LogOnly -LogLevel Full

This command searches all mailboxes for messages that the sender is user2 and the sent time from 7/1/2022 to 7/20/2022, then logs the result in the SearchAndDeleteLog folder in the administrator’s mailbox. Messages aren’t copied to the target mailbox.

@anuraag-systools ​ You do understand that what you posted is just a file name, not a script.

You did not post a link for OP, so OP can not run that…

I assume it is this?

We use the Message Tracking GUI linked below to create various queries on our Exchange 2016 servers based on information from the tracking logs. Not what you are looking for but the GUI also shows you the resulting Powershell command which you can use for documenting or further processing. Maybe this will help you.

HTH Tom

1 Spice up

Hi

If the issue has been solved.

I’d appreciate it if you choose the most helpful post above and mark it as the best answer, this will make answer searching in the forum easier and be beneficial to other community members as well. Thanks!

Is there any update about this issue?

How’s everything going?