How to count PDF attachments in each mailbox (Exchange Server 2010)? RRS feed

  • Question

  • Hello, is there a command that can send a log containing the total amount of pdf files within each mailbox? I tried the following but it did not work. Any help is appreciated. Thank you.

    New-MailboxSearch -Name Test -SearchQuery "attachment:pdf" -LogLevel Full -TargetMailbox

    Thursday, June 23, 2016 2:43 PM

All replies

  • What results did you get from your search?  I'd try the following command:

    New-MailboxSearch -Name Test -SearchQuery "attachment:'.pdf'" -LogLevel Full -TargetMailbox

    HTH ...

    Will Martin ...
    -join ('77696c6c406d617274696e2d66616d696c6965732e6f7267' -split '(?<=\G.{2})' | ? { $_ } | % { [char][int]"0x$_" })

    Thursday, June 23, 2016 3:16 PM
  • Hi Will. It returns the info below immediately. It does say 'InProgress' so it is possible it is going through the mailboxes... I'm not sure if what I want is possible. I will have to read the documentation on new-mailboxsearch

    RunspaceId: <characters>
    Identity: <characters>
    Name: Test
    CreatedBy: domain\administrator
    SourceMailboxes: {}
    TargetMailbox:  Smith
    SearchQuery: attachment:'.pdf'
    Language: en-US
    Senders: {}
    Recipients: {}
    MessageTypes: {}
    SearchDumpster: True
    IncludeUnsearchableItems: False
    DoNotIncludeArchive: False
    EstimateOnly: False
    ExcludeDuplicateMessages : True
    Resume: False
    LogLevel: Full
    StatusMailRecipients: {}
    Status: InProgress
    LastRunBy: Administrator
    LastStartTime: 23/06/2016 11:30:54 AM
    NumberMailboxesToSearch: 0
    PercentComplete: 0
    ResultNumber: 0
    ResultNumberEstimate: 0
    ResultSize: 0 B (0 bytes)
    ResultSizeEstimate: 0 B (0 bytes)
    ResultSizeCopied: 0 B (0 bytes)
    Errors: {}
    KeywordHits: {}
    Thursday, June 23, 2016 4:07 PM
  • You do see the difference between the command you used and the one I entered above, right?  I've places the . in front of pdf, and I've placed this in single quotes - so -SearchQuery "attachment:'.pdf'" versus -SearchQuery "attachment:pdf" ...  There is a difference.

    Also, I believe that the empty "sourcemailbox" parameter means you are searching every mailbox in your organization - and this will take a long time, so I'd expect it to still be running, even if it found no results.

    Will Martin ...
    -join ('77696c6c406d617274696e2d66616d696c6965732e6f7267' -split '(?<=\G.{2})' | ? { $_ } | % { [char][int]"0x$_" })

    Thursday, June 23, 2016 5:29 PM
  • Yes I understand the difference. I'll have to remember the proper syntax from now on. I did some reading and the command below worked for me. I'm not sure how accurate it is in finding every filetype within a mailbox so I am going to pick a few accounts and compare the results from the csv file. Thanks for the assistance, Will. 

    Get-Mailbox | Search-Mailbox -SearchQuery "attachment:'.pdf'" -TargetMailbox -TargetFolder testfolder -LogOnly -LogLevel Full

    Thursday, June 23, 2016 8:17 PM
  • Glad we were able to help you out ...  Feel free to mark the responses that answered your question(s).

    Will Martin ...
    -join ('77696c6c406d617274696e2d66616d696c6965732e6f7267' -split '(?<=\G.{2})' | ? { $_ } | % { [char][int]"0x$_" })

    Friday, June 24, 2016 5:26 PM