Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Spam cleanup of internal exchange mail system

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

In the process of using the internal mail system, it is inevitable to receive some spam, and these spam also occupy certain user mailbox resources. This document introduces the use of exchange management shell tools to delete these spam within exchange server in batches.

Example:

Example 1:

This example searches for the mailbox of JoeHealy and copies the search results to DiscoveryMailbox in the JoeHealy-ProjectHamilton folder

Search-Mailbox-Identity "JoeHealy"-SearchQuery "Subject:Project Hamilton"-TargetMailbox "DiscoveryMailbox"-TargetFolder "JoeHealy-ProjectHamilton"-LogLevel Full

Example 2:

This example searches for messages in April Stewart's mailbox whose subject contains the phrase "Your bank statement" and records the results in the SearchAndDeleteLog folder of the administrator's mailbox. Messages will not be copied to the destination mailbox.

Search-Mailbox-Identity "April Stewart"-SearchQuery 'Subject: "Your bank statement"'-TargetMailbox "administrator"-TargetFolder "SearchAndDeleteLog"-LogOnly-LogLevel Full

Example 3:

This example searches for messages in April Stewart's mailbox whose subject contains the phrase "Your bank statement", and then deletes them from the source mailbox. You must be assigned the Mailbox Import and Export administrative role to use the DeleteContent switch.

Search-Mailbox-Identity "April Stewart"-SearchQuery 'Subject: "Your bank statement"'-DeleteContent

The above are some examples of the use of search-mailbox given by Microsoft officially for exchange2013, according to which we make some changes to meet the spam needs of our enterprise.

Examples of requirements:

1. Delete an email whose sender is "Please transfer to relevant departments" from a mailbox within the enterprise. Here, take the testzhang user as an example.

Open exchange management shell and use the following command

Search-Mailbox-Identity "testzhang"-SearchQuery 'from: "Please transfer to relevant departments"'-TargetMailbox "administrator"-TargetFolder "SearchAndDeleteLog"-LogOnly-LogLevel Full

Search for all senders in the testzhang user mailbox that contain the keyword "Please transfer to the relevant department" and send the search results to the SearchAndDeleteLog folder in the administrator mailbox. (change the from parameter to subject if you want to search for a specific keyword)

As you can see, when we find 3 similar emails, we can open the administrator mailbox to see the specific search results.

Note that when the above command is executed, the following red box starts to be failed and needs to wait for a few minutes, depending on the number of searches. When the status changes to succeeded after refreshing the mailbox interface, the search is complete. The specific search results are in the attachment search resu~.zip, which we download to view.

Extract the attachment and open the file in text mode

If you want to open the csv document in excel, you need to change the mode, otherwise it will be garbled, click on the file, save as, change the encoding to ANSI, save and replace the original file

When you open it with excel again, you can see that the sender is: please transfer to the user of the relevant department and send three emails to testzhang

After confirming that the above messages are spam, you can delete these spam messages with the following command.

Search-Mailbox-Identity "testzhang"-SearchQuery 'from: "Please transfer to relevant departments"-DeleteContent

You can search the mailbox again with the above search command to confirm that "Please transfer to the relevant department email" has been cleared.

2. Delete the mail whose sender is "Please transfer to the relevant department" from all mailboxes within the enterprise.

Run the following command on exchange management shell

Get-Mailbox | Search-Mailbox-SearchQuery 'from:'-TargetMailbox "administrator"-TargetFolder "SearchAndDeletelog"-LogOnly-LogLevel full

Search all mailboxes in the enterprise with the sender of "Please transfer to the relevant department" and send the search results to the administrator mailbox.

This command may take 5-10 minutes, depending on the number of users, because it searches all users' mailboxes.

The search process... Will search the mailbox one by one.

Display 0B means that the mailbox does not have qualified spam, wait for the search to complete, go to the administrator mailbox to view the specific search results. It may take some time to change from failed to succeeded due to the large amount of searches.

You can see the following search results

At present, more than 4, 000 records have been searched. If more than 10000 records are recorded, use the new-mailboxsearch command according to the command prompt

Note: you need to confirm that the above messages are all spam before you can use the following command to remove these spam messages so as to avoid mistakenly deleting normal messages.

Get-Mailbox | Search-Mailbox-SearchQuery 'from: "Please transfer to relevant departments"-DeleteContent

It also takes some time to clear depending on the number of messages.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 272

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report