Exchange 2010 Powershell question

I am trying to run a powershell command that will list all items above a certain size in a csv similar to this below but I need it to list all items not just the top subject:

Get-Mailbox -identity alias| Get-MailboxFolderStatistics -IncludeAnalysis -FolderScope All | Where-Object {$_.TopSubjectSize -gt 5MB -and $_.TopSubjectReceivedTime -gt "7/21/2014 00:01"} | Select-Object Identity, TopSubject, TopSubjectSize, TopSubjectReceivedTime | Export-CSV -path "C:\report.csv" -notype

Any help is greatly appreciated.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
Not sure what the issue is here?

The command that you have posted works completely fine in my Lab environment. I had to adjust the gt to lt but overall the command works completely fine and exports to the CSV with no issues.

Minecraft_ EndermanCommented:
If you are trying to list all items above a certain size for entire mailbox not for separate folders. Replace the Get-MailboxFolderStatistics cmdlet with Get-MailboxStatistics.

Get-Mailbox -identity alias| Get-MailboxStatistics | Where-Object {$_.TotalItemSize -gt 5MB} | Select-Object Identity, TotalItemSize | Export-CSV "C:\report.csv"

If you want to list each item subject under a specific folder, perhaps this command will not do this.
Guy LidbetterCommented:
Hi There,
If you are looking for every item inside a mailbox that is above a certain size, that is more difficult.
Neither of the solutions above would provide what you are looking for.

I imagine running a Search-Mailbox with a query like -SearchQuery "Size:>5MB" may get some details, but it doesn't report on the actual file size.

Get-MailboxFolderstatics will only ever report the largest single item per folder.
Get-MailboxStatistics will only show you the total size of all messages in the mailbox.

I'm actually not sure if you can actually get the details you want without going directly into it with a MAPI tool like MFCMAPI.

I'll have a look around though...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud as a Security Delivery Platform for MSSPs

Every Managed Security Service Provider (MSSP) needs a platform to deliver effective and efficient security-as-a-service to their customers. Scale, elasticity and profitability are a few of the many features that a Cloud platform offers. View our on-demand webinar to learn more!

Guy LidbetterCommented:
I'm having limited success with this code, see if it works for you. As mentioned - it does not return individual item sizes, but it does return something. This generates a log that generates a report and it gets copied to the Export Folder in your own mailbox (It will create it...)

Get-mailbox -resultsize unlimited | search-mailbox -targetmailbox YourMailBox -targetfolder 'Export' -searchquery "Size:>5MB" -logonly -loglevel full 

Open in new window

Will SzymkowskiSenior Solution ArchitectCommented:
I am using this exact code in Exchange 2010 SP3 and it works with or without exporting to csv.

Get-Mailbox -identity alias| Get-MailboxFolderStatistics -IncludeAnalysis -FolderScope All | Where-Object {$_.TopSubjectSize -lt 1KB -and $_.TopSubjectReceivedTime -lt "7/21/2014 00:01"} | Select-Object Identity, TopSubject, TopSubjectSize, TopSubjectReceivedTime | Export-CSV -path "C:\report.csv" 

Open in new window

I have changed the TopSubjectSize to -lt 1KB and TopReceivedTime -lt "7/21/2014 00:01" and it works without any issues and i get my results. I have changed the initial switches due to this being a lab environment.

Guy LidbetterCommented:
Will, I assume are are receiving one entry per mailbox folder?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.