I need to run a report of all Mailboxes in Exchange that contain a specific folder, and those that don't contain that specific folder.
I am able to get the results I need of the specific folder using this command:
Get-Mailbox username | Get-MailboxFolderStatistics | Where {$_.name -match "Company Reports"} | Select-Object Identity| Export-csv c:\Nocompanyreports.csv -NoTypeInformation
This returns one line with the folder path:
DOMAIN.COM/Company/Users/Username\Company Reports
The problem I am facing is when running the -notmatch or -notlike switch, where it will return all other folders in that user's mailbox. Ideally, I would like to return the OrganizationalUnit or Identity of the mailbox user attribute, if the mailboxfolderstatistics do not contain the Company Reports folder.
Thank you in advance.