You have moved your mailboxes to Office 365 Exchange Online and license the users. However, it is a common issue that if an employee moves on, Active Directory account sometime remains active. That, of course, doesn’t release the license in Office 365.
When above issue happens, our customers (not our managed Services costumers) calls us and indicates that they are running out of licenses.
In order to avoid above issue, it would be better to gather a report that shows the mailboxes that haven’t been accessed for a while.
You can a PowerShell and gather the report, export to CSV and sort it with last login time. This is the way we used to have. However, now, Office 365 Admin console provide the same report and you can export it.
Gathering the report is really easy. Go to Admin panel>Report>Usage
Select the mailbox Usage from the combo-box
Last step is to sort it with “Last activity date”. If you want, you can export it to CSV file too