question

junidev-0033 avatar image
junidev-0033 asked ·

Get list of Azure users with specific License

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

azure-active-directory
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

BijuThankappan-5910 avatar image
BijuThankappan-5910 answered ·

Hi, @junidev-0033 see if this helps.


1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Biju,

Thanks for your collaboration, but it is the same thing I have (and using an older PS).
We both are getting all the users first and only after that we verify the licenses.
I would like a way to pass the filter to the query so the response time would be optimized

Thanks and regards,
JD

0 Votes 0 · ·
michev avatar image
michev answered ·

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.

Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

VaibhavPatel-5661 avatar image
VaibhavPatel-5661 answered ·

Hi @junidev-0033

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

Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

theodorbrander avatar image
theodorbrander answered ·

Hi junidev,

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

-T



Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.