I'm currently working on an audit for about 2300 users to check how many have multiple Microsoft 365 licenses (E3 and F3). When I look at the licensing groups in Entra, I can see the list of users, but unfortunately, there's no option to export this data. I'm looking for the best way to identify users who have duplicate licenses, and I'd also like to know how to automate this process in the future to prevent it from happening again.
We assign licenses based on groups (like F3 assigned and E3 assigned), and I'm questioning if this is the best approach. I've considered a couple of potential solutions, but I'm not very familiar with Entra's capabilities:
1. Write a script that removes all groups and licenses from a user when they're disabled, unless they are added to an exception group first.
2. Set a rule in the licensing groups that prevents users assigned to the E3 group from also being assigned to the F3 group.
I would appreciate any insights or suggestions from the community to make this process smoother for next year, so I don't have to manually verify all 2300 users.
1 Answer
You can likely do this with the Graph API using PowerShell. It allows for pulling user information programmatically, which is perfect for your situation. If you're not super comfortable scripting, don't worry; I can break it down for you. Here's a rough idea of how your code might look:
```powershell
Connect-MGGraph -scopes Users.Read.All, Groups.Read.All
$Allusers = Get-MGUser -all
$Export = @()
foreach ($user in $Allusers) {
if (!$user.assignedLicenses) { continue }
$Summary = [pscustomobject]@{ name = $user.displayName; licenses = $user.assignedLicenses }
$Export += $Summary
}
$Export | Export-CSV -NoTypeInformation -Path "allUsersLicenses.csv"
```
This script gets all the users and their licenses, allowing you to filter for duplicates later.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures