M365 Licensing using msol and AzureAD powershell

M365 licensing can be tricky sometime. Below cmdlt flow will help you sort out your tenant licensing information properly.

PS C:\> Install-Module AzureAD
PS C:\> Connect-AzureAD
PS C:\> Install-Module MSOnline
PS C:\> Connect-MSolservice

Next lets get the list of all the purchased license, consumed unit and available units.

PS C:\> Get-AzureADSubscribedSku | Select -Property SkuPartNumber, ConsumedUnits -ExpandProperty PrepaidUnits | Format-Table

We can see from above skuPartNumber represent the type of license. We have 69 “ENTERPRISEPACK” licenses in this tenant. The SkuPartNumber for each does not precisely match the name of the license that we will see in Microsoft 365 admin portal e.g. ENTERPRISEPACK is the SkuPartNumber for the office 365 E3, while MCOEV is the SkuPartNumber for the Phone system license.

Ok so next comes ServicePlanName , these are plans under SkuPartNumber . These are individual license features and services also referred to as sub-SKU features, can also be inspected. As with the SkuPartNumber values, the ServicePlanName values are not a match for the friendly names that you see in the Microsoft 365 or Azure admin portals.

PS C:\> $license=Get-AzureADSubscribedSku
PS C:\> $licenses[3].SkuPartNumber 
ENTERPRISEPACK
PS C:\> $licenses[3].Serviceplans

Ok, so now we know about license bought/allocated. Next part comes to user side, what license are assigned to the user, Or who all users are assigned with a particular license.

So lets check what all licenses are assigned to a user.

PS C:\> Get-msoluser -SearchString user@cloudmechanics.in| ft UserPrincipalName, @{L='Licenses Assigned'; E={($_.licenses).Accountskuid}}

Ok lets dig further and see what are service plan assigned to the user.

PS C:\> (Get-AzureADUser -objectid user@cloudmechanics.in | Select-Object AssignedPlans).AssignedPlans

Next, lets get the list of all the users assigned with one particular license type, here we will get all the users list who are assigned with “ENTERPRISEPACK”, i.e. O365 Enterprise E3:

PS C:\> Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -match "ENTERPRISEPACK"}

Ok Next, steps let get the list of all the users assigned with a particular service plan inside License plan

PS C:\> Get-MsolUser | ? {$_.Licenses.ServiceStatus | ? {$_.ServicePlan.ServiceName -eq "TEAMS1" -and $_.ProvisioningStatus -eq "Success"}}

Complete list of friendly name can be fetched from below link:

https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-service-plan-reference

This entry was posted in Azure, Powershell. Bookmark the permalink.

Leave a Reply

Your email address will not be published.