question

BhlerGabriel-0640 avatar image
0 Votes"
BhlerGabriel-0640 asked DaniloCrivellaro-2246 answered

Exporting all Users with specific licenses to CSV

Hello Everyone

I am trying to export all users with specific licenses into a csv-file. Here is the command I've been trying to use:

 Get-MsolUser -all | Select FirstName, LastName, DisplayName, City, Country, PrincipalName, Title, Department, Licenses | Where-Object {($_.Licenses).LicenseAssigned  -match "PROJECTPROFESSIONAL" -or "PROJECTPREMIUM" -or "PROJECTESSENTIALS" -or "POWER_BI_PRO" } | export-csv C:\export5.csv -NoTypeInformation -Encoding UTF8 -Append

Unfortunately the export doesn't give me the licenses, only this entry: System.Collections.Generic.List`1[Microsoft.Online.Administration.UserLicense]

What am I doing wrong? My goals is to see all the details I mentioned plus if they are using the licenses, which of the licenses they are having.

Thank you for your Help.

Kind regards,


Gabriel

windows-server-powershellazure-ad-domain-services
5 |1600 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.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

There are many examples of how to do this if look for them. Try searching for something like "powershell export msol users with licenses".

Here's just one result: export-list-office-365-users-licenses-customer-tenants-delegated-administration


5 |1600 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.

MarileeTurscak-MSFT avatar image
0 Votes"
MarileeTurscak-MSFT answered MarileeTurscak-MSFT edited

Hi @BhlerGabriel-0640,


You need to search by AccountSkuId.

Specifying the tenant name:

 Get-MsolUser -UserPrincipalName $audituser | Select-Object -ExpandProperty Licenses | Where-Object {$_.AccountSkuID -eq $TenantName + ':POWER_BI_PRO'}

The tenant domain name prefixes the SKU:

 Get-MsolUser -all | Select FirstName, LastName, DisplayName, City, Country, PrincipalName, Title, Department, Licenses | Where-Object{ $_.Licenses.AccountSkuId -match "tenantdomainname:PROJECTPREMIUM" }

Additional examples:

Users with a specific license

Automate user license

Get users with multiple specified licenses

Project SKU


5 |1600 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.

DaniloCrivellaro-2246 avatar image
0 Votes"
DaniloCrivellaro-2246 answered

@BhlerGabriel-0640

Try this:


Get-MsolUser -All |select UserPrincipalName,@{n="Licenses Type";e={$_.Licenses.AccountSKUid}} | Export-CSV c:\temp\users.csv


5 |1600 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.