How to report on licensed Office 365 users with disabled Active Directory accounts

There may be times where you need to do some housekeeping on your Office 365 licenses.  Users may have left, for example, had their active directory accounts disabled, but are still consuming a license in Office 365.  Here is a simple powershell one-line that will output a report to CSV.

Connect powershell to Azure AD for your Office 365 subscription as described here and run the following

Get-MsolUser -All -EnabledFilter DisabledOnly | where {$_.isLicensed -eq $true} | select DisplayName,UserPrincipalName,BlockCredential,Islicensed | Export-Csv c:\temp\licensereport.csv -NoTypeInformation

 

This will give you a report on all licensed Office 365 users with disabled active directory accounts.

 

One thought on “How to report on licensed Office 365 users with disabled Active Directory accounts

Leave a comment