How can I get O365 Licensed user list via PowerShell?

  • 29 April 2021
  • 4 replies

Userlevel 2
Badge +8

Does anyone have a PowerShell command that will retrieve the users that license summary report would report on?

I’ve used Get-SPO -Limit All before to get a list of users but this seems to get more users than CV reports on. I want to extract what CV would report on before implementing backups (I have an account to be able to do this) to ensure the correct number of licenses are purchased.

I have seen reference to getting the list in the logs (when watching/investigating issues) but haven’t seen the command used.


Best answer by Sridhar 29 April 2021, 22:24

View original

4 replies

Userlevel 3
Badge +5

Hi @Mike London UK !

I'm not aware of any PowerShell commands to retrieve that information (though if anyone else does, feel free to chime in), however, I wanted to ask you what is the end goal with O365 the licensed users list? Maybe there is another way to achieve the same or similar.

Since this information is already provided by the CommCell License Summary Report, you could filter by the “usage based license” you are interested on and select the output as comma delimited .csv (Text) to then process it as desired.


Another way I can think of is using REST API call to get the Web License Summary Report (Users) Data Set (This operation returns a data set from a report)


Hope it helps!


Best regards,

Sarahy Pardo


Userlevel 2
Badge +8

Thanks Sarahy, we haven’t added the customer into our system yet. We are in the discovery phase and one of the conversations was around the number of users sold to them (low hundreds) and their actual user count (low thousands). Exchange and OneDrive users can be configured by AD group membership and the license summary report will report accurately against the group(s). However, the main factor is the number of users licensed for SharePoint as the report will take those and the Exchange, OneDrive users and count unique users to give a license number.

I’m wanting to pre-empt any large discrepancy whilst I wait for some other information on their implementation to come though.


Badge +1

Here is the command which will list SharePoint enabled users in the tenant. During backup we count the same users.

Get-MsolUser -All | where {($_.isLicensed -eq "True")} | where {$_.Licenses.ServiceStatus | where {($_.ServicePlan.ServiceType -eq "SharePoint") -and ($_.Provisioningstatus -eq "Success")}}| Format-List | Out-File c:\Office365licensedusers.csv

Considerations for SharePoint (online or on-premise) When SharePoint backups (covered under the Mail/Cloud App licensing) are undertaken, all users in an organization that are licensed for read/write access to the SharePoint environment must be licensed for backup. External and nonauthenticated users do not need to be counted in the overall total.

Userlevel 2
Badge +8

Thanks @Sridhar that is useful. I’ve amended the command to the below for a true CSV output with a limited number of fields (obtainable from the file create by the command supplied).

Get-MsolUser -All | where {($_.isLicensed -eq "True")} | where {$_.Licenses.ServiceStatus | where {($_.ServicePlan.ServiceType -eq "SharePoint") -and ($_.Provisioningstatus -eq "Success")}}| select UserPrincipalName,signinname,displayname,islicensed,licenses | Export-Csv -NoTypeInformation -Path .\Office365-SharePointLicensedusers.csv

Many thanks for your help