none
Search-Mailbox command now failing. Has something to do with attachment size

    問題

  • We have been using the command below for years searching through mailboxes to remove spam or possibly malicious emails. Always worked great. We run it first in logLevel Full mode and then add the -DeleteContent Switch.

    get-mailboxserver | Get-Mailbox -resultsize unlimited | Search-Mailbox -SearchQuery "From:"emailaddress.com" -TargetMailbox "Suspect Emails" -TargetFolder "Phish" -LogLevel Full

    Recently when running the command we are now getting the error below. I know the reason why we are getting the error. I just don't know what to do to fix it. The queries we are running now are returning much larger results. Basically every mailbox and it looks like it cannot create the Excel worksheet. If I run it on each mailbox server separately, it seems to run OK because I am only hitting half the mailboxes. Is there a swtich or setting I can implement to override this error?

    Cannot open attachment.
        + CategoryInfo          : InvalidArgument: (:) [], AttachmentExceededException
        + FullyQualifiedErrorId : 274AF090

    2018年5月18日 下午 01:47

所有回覆

  • Hi shadowtuck,

    Could you use the command below to search for just one mailbox successfully?

    Search-Mailbox -SearchQuery {From:"xxx@xxx.xxx"} -TargetMailbox "xxx@xxx.xxx" -TargetFolder "xxx" -LogLevel Full

    I guess there has a limit about search-mailbox, if you can search for just on mailbox, you can use the script below to search for all mailbox:

    $mailboxes = Get-MailboxServer | Get-Mailbox -resultsize unlimited
    
    foreach($mailbox in $mailboxes){
    
    Search-Mailbox -Identity $mailbox.name -SearchQuery {From:"xxx@xxx.xxx"} -TargetMailbox "xxx" -TargetFolder "xxx" -LogLevel Full
    
    } 
    

    Regards, 

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年5月21日 上午 06:13