SOLVED

Get list of inactive users with licenses assigned in Microsoft 365

%3CLINGO-SUB%20id%3D%22lingo-sub-2808185%22%20slang%3D%22en-US%22%3EGet%20list%20of%20inactive%20users%20with%20licenses%20assigned%20in%20Microsoft%20365%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2808185%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20Microsoft%20365%20tenant%20with%20more%20than%201000%20users%20in%20it.%20I%20need%20to%20get%20a%20list%20of%20users%20who%20have%20not%20been%20active%20for%20the%20last%20180%20days%20but%20are%20assigned%20with%20licenses.%20The%20goal%20is%20to%20check%20if%20users%20left%20the%20company%20but%20never%20removed%20their%20licenses%20although%20inactive%2C%20which%20is%20a%20waste%20of%20money.%20Please%20advice.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2808185%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2808213%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20list%20of%20inactive%20users%20with%20licenses%20assigned%20in%20Microsoft%20365%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2808213%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F52162%22%20target%3D%22_blank%22%3E%40Dileepa%20S.Rajapaksa%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20link%20below%20should%20be%20the%20perfect%20answer%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Freports-monitoring%2Fhowto-manage-inactive-user-accounts%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Freports-monitoring%2Fhowto-manage-inactive-user-accounts%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2808261%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20list%20of%20inactive%20users%20with%20licenses%20assigned%20in%20Microsoft%20365%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2808261%22%20slang%3D%22en-US%22%3EThanks%2C%20but%20this%20does%20not%20have%20a%20way%20to%20get%20users%20with%20licenses%20assigned%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2811591%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20list%20of%20inactive%20users%20with%20licenses%20assigned%20in%20Microsoft%20365%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2811591%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1142046%22%20target%3D%22_blank%22%3E%40Thijoubert%3C%2FA%3E%26nbsp%3Bi'm%20getting%20the%20following%20error%20in%20Graph%20API%20when%20try%20this.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202021-10-05%20at%201.59.12%20PM.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F315160i89382FECC09FFAA7%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot%202021-10-05%20at%201.59.12%20PM.png%22%20alt%3D%22Screenshot%202021-10-05%20at%201.59.12%20PM.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
MVP

I have a Microsoft 365 tenant with more than 1000 users in it. I need to get a list of users who have not been active for the last 180 days but are assigned with licenses. The goal is to check if users left the company but never removed their licenses although inactive, which is a waste of money. Please advice. 

8 Replies
Thanks, but this does not have a way to get users with licenses assigned
best response confirmed by Dileepa S.Rajapaksa (MVP)
Solution
To be more precise you could:

1/ Get all the users with licenses assigned
The most simple solution is: Get-MsolUser -All | where {$_.isLicensed -eq $true}

To go further, I use several custom scripts :
- To get a list of the licenses assigned to a user (ex : Office 365 E3) : https://github.com/thijoubert/Sharing/blob/main/PowerShell/AAD_Licenses_Users.ps1
- To get a full list of the SKU assigned to a user (ex : SharePoint Online P2) : https://github.com/thijoubert/Sharing/blob/main/PowerShell/AAD_Licenses_Users_Details.ps1

2/ Get the last sign-in date for you users:
The most simple solution : https://docs.microsoft.com/en-us/azure/active-directory/reports-monitoring/howto-manage-inactive-use...
You could use Graph explorer with an admin account

3/ Cross-reference the two lists to get your answer

@Thijoubert i'm getting the following error in Graph API when try this.

Screenshot 2021-10-05 at 1.59.12 PM.png

 

Did you grant the relevant permissions?
- User.Read.All
- Directory.Read.All
- Auditlogs.Read.All
In the modify permission tab I cannot see the Auditlogs.Read.All... Where can I locate them?

@Dileepa S.Rajapaksa 

You can find it here: 

Thijoubert_1-1633426075783.png

Hope this helps

 

Thank you so much this saved my life...