Get list of Azure users with specific License

juni dev 336 Reputation points
2019-12-16T17:08:16.137+00:00

Hi,
I need to get a lsit of users with a specific O365License.
I'm using this:
$ulist=Get-AzureADUser -All 1 | Select userprincipalname -ExpandProperty AssignedLicenses | Where-Object {$_.SkuID -eq '6fd2c87f-b296-42f0-b197-1e91e994b900'} | select userprincipalname

Is there a better/faster way to achieve this?

Thanks,
JD

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,502 questions
0 comments No comments
{count} vote

5 answers

Sort by: Newest
  1. Phill (Radar) Kenyon 6 Reputation points
    2021-02-09T20:01:53.377+00:00

    dear sir, i built on your path & did the following "get-azureaduser -all 1 | select upn -expandproperty licenses | select upn,skuid | ? skuid -match "skustring"
    this is very fast, and if you can over look some psuedo syntax, allows for some pretty good results. * the 2nd select allows you to ? very easily.

    1 person found this answer helpful.
    0 comments No comments

  2. theodorbrander 51 Reputation points
    2019-12-18T13:16:35.773+00:00

    Hi junidev,

    An alternative to Powershell would be the portal.
    Open the AAD blade->groups->members->Download members

    -T

    0 comments No comments

  3. Vaibhav Patel 6 Reputation points
    2019-12-18T10:36:49.173+00:00

    Hi @juni dev

    Please find below script which will give you the all services for a user who has been assigned multiple license

    $userUPN=""
    $AllLicenses=(Get-MsolUser -UserPrincipalName $userUPN).Licenses
    $licArray = @()
    for($i = 0; $i -lt $AllLicenses.Count; $i++)
    {
    $licArray += "License: " + $AllLicenses[$i].AccountSkuId
    $licArray += $AllLicenses[$i].ServiceStatus
    $licArray += ""
    }
    $licArray

    OR

    This will give you the all users with specific license

    Get-MsolUser | Where-Object {($_.licenses).AccountSkuId -match "EnterprisePremium"} | Out-file C:\temp\result.csv

    1 person found this answer helpful.
    0 comments No comments

  4. Vasil Michev 95,571 Reputation points MVP
    2019-12-17T17:42:36.753+00:00

    There's no server-side way to filter this, as the stupid ODATA syntax used by the Graph has very limited filtering capabilities and the assignedLicenses practically cannot be used.

    1 person found this answer helpful.
    0 comments No comments

  5. Biju Thankappan 101 Reputation points
    2019-12-16T17:25:04.19+00:00

    Hi, @juni dev see if this helps.