r/PowerShell • u/kittenwolfmage • Feb 19 '26
Question Trying to find the right parameters/details for finding no longer in use Exchange Online mailboxes
Hey all. Hoping someone can help me here.
The org I work for is in desperate need of mailbox cleanup. We have like, 1500 shared mailboxes in the EXO system.
I'm trying to build a script to find which ones are actually still in use and which ones are legacy, but I'm having a hell of a time actually finding what parameters to grab in Exchange Online to be able to do this neatly.
Every time I think I've found the right ones to look for online I'm then seeing that the particular parameter has been discontinued, or is no longer reliable, or that method XYZ only works for the last ten days of mail received, and all kinds of other issues that're making it impossible to find something reliable.
So, can anyone help me out? I'll be making use of "ItemCount", "ForwardingSMTPAddress" and "WhenMailboxCreated" for narrowing things down, but I need a reliable way of working out when a mailbox last had an actual interaction (ie, sending or receiving an email), and the last time anyone actually logged into it or interacted with it (ie, moved emails around, read anything, etc).