In some cases
$sentItems = Get-EXOMailboxFolderStatistics -Identity $.UserPrincipalName -Folderscope sentitems_
returns details for additional folders and not only the Sent Items folder, resulting in the error as per title of this issue.
It can be corrected (and I have successfully tested) by qualifying using "| Where {$_.FolderPath -eq "/Sent Items"} ", as follows.
In some cases $sentItems = Get-EXOMailboxFolderStatistics -Identity $.UserPrincipalName -Folderscope sentitems_
returns details for additional folders and not only the Sent Items folder, resulting in the error as per title of this issue.
It can be corrected (and I have successfully tested) by qualifying using "| Where {$_.FolderPath -eq "/Sent Items"} ", as follows.
Replace
$sentItems = Get-EXOMailboxFolderStatistics -Identity $.UserPrincipalName -Folderscope sentitems | Select-Object ItemsInFolderAndSubfolders,@{Name = "sentItemSize"; Expression = {$.FolderAndSubfolderSize.ToString().Split("(")[0]}}
with
$sentItems = Get-EXOMailboxFolderStatistics -Identity $.UserPrincipalName -Folderscope sentitems | Where {$_.FolderPath -eq "/Sent Items"} | Select-Object ItemsInFolderAndSubfolders,@{Name = "sentItemSize"; Expression = {$.FolderAndSubfolderSize.ToString().Split("(")[0]}}