How about Get-EXOMailboxFolderStatistics?
Powershell Office 365 emails
Does anybody know if below is possible by Powershell - I have asked Microsoft support they said it is not possible.
A way of seeing the top 100 emails (or emails over 10mb) in a given shared / group mailbox - so as to check if people are sending / receiving files that are massive. | Sender | Recipient | Date | Email size in MB | and export it to a .CSV file
3 answers
Sort by: Most helpful
-
-
SJ Hirani 1 Reputation point
2021-01-25T15:39:11.94+00:00 Thanks for your help Rich
Only need top 100 highest email size, If i do that it will not show me each email size. -
Rich Matheisen 45,186 Reputation points
2021-01-26T16:04:48.88+00:00 If you're doing this from a machine on which Outlook is installed you can try using this instead of EWS or trying to get Invoke-RestMethod (and having to deal with OAUTH2 authentication). It's only going to look in the "Default" folder in this example, but you can change that if the messages are in some other folder. If you want to deal only with messages over 10MB just add a Select-Object just before the Foreach-Object to check for "$_.Size -gt 10MB".
Add-Type -assembly "Microsoft.Office.Interop.Outlook" Add-Type -assembly "System.Runtime.Interopservices" try { $outlook = [Runtime.Interopservices.Marshal]::GetActiveObject('Outlook.Application') $outlookWasAlreadyRunning = $true } catch { try { $Outlook = New-Object -comobject Outlook.Application $outlookWasAlreadyRunning = $false } catch { write-host "You must exit Outlook first." exit } } $namespace = $Outlook.GetNameSpace("MAPI") $inbox = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox) $inbox.Items | ForEach-Object{ [PSCustomObject]@{ Subject=$_.Subject Size=$_.Size From=$_.SenderEmailAddress } } | Sort-Object Size -Descending | Select-Object -First 100 # Close outlook if it wasn't opened before running this script if ($outlookWasAlreadyRunning -eq $false) { Get-Process "*outlook*" | Stop-Process -force }