Hi @KyleXu-MSFT
Thank you for reply.
Kindly note the script is to be run on office 365 accounts which have archive enabled. Can you kindly modify the script as you have mentioned for me to try out again.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have created a simple custom PowerShell Script to export the total email or item count in office 365 archive mailboxes for all users who have online archiving enabled. However the script does not return the correct result. I called ItemCount
with Get-mailboxstatistics
object.
In my office 365 I have one user account with online archiving enabled, the archive mailbox has three emails that I archived and then run start-managedfolderassistant
cmdlet for that user.
The script still returns one item. What I'm I doing wrong. I'm expecting three itemcount.
Kindly assist.
Below is my script.
`$mails = get-mailbox -ResultSize Unlimited -archive
$mails | foreach-object{
$mailbox = $_.UserPrincipalName
$username = $_.DisplayName
$archive = get-mailboxstatistics -Identity $mailbox -archive
New-object -typename PSobject -property @{
UserPrincipalName = $mailbox
UserName = $username
TotalMessagesCount = $archive.ItemCount
}
} | Export-CSV "c:\results7.csv" -NoTypeInformation -Encoding UTF8`
Hi @KyleXu-MSFT
Thank you for reply.
Kindly note the script is to be run on office 365 accounts which have archive enabled. Can you kindly modify the script as you have mentioned for me to try out again.
Anyone following this question can help? I will appreciate. Thank you.
Something like this??
$root = Get-MailboxFolderStatistics -Identity <user>
$root | Select-Object FolderPath, VisibleItemsInFolder | Sort-Object -Property FolderPath