O365 E5 Licence report

Iron Contributor

Hi - I am trying to use Powershell to return a report of all users who have the Power BI pro option enabled under office 365 E5.


To clarify, this is not the Power BI Pro licence that can be purchased separately, our users are licenced via their E5 licence.


I have tried the following:


(Get-MsolAccountSku | where {$_.AccountSkuId -eq "hopuk:ENTERPRISEPREMIUM"}).ServiceStatus
This just returns the E5 licence and I can't go down a level into the services beneath it.
I've also tried the following (kindly supplied by a colleague):

# Connect to the SPO Service

# The license - enterprise pack is E3 and enterprise premium is E5
$AccountSkuId = "<mydom>ENTERPRISEPREMIUM"


# The service that you want the script to check - https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-service-plan-refe...
$Lserivce = "BI_AZURE_P2"


# Get all the users in the tenant, this query takes 1 to 2 minutes
$allusers = Get-MsolUser -MaxResults 20000 | Where-Object { $_.isLicensed -eq "TRUE" }


# Set counter up
$number = 0
$numberofusers = $allusers.count


# For each user found
foreach ($user in $allusers.UserPrincipalName)




# Add 1 to counter after each user
write "Processing $number \ $numberofusers $($user)"


# Get the license details
$licensedetails = (Get-MsolUser -UserPrincipalName $user ).Licenses | Where {$_.AccountSkuId -eq $AccountSkuId}



# Get all the services in the license for that user, only return the services that have been activated
$service = $licensedetails.ServiceStatus | Where {$_.ProvisioningStatus -eq "success"}


# Get just the names of the services for the user stripping everything else out
$results = $service.serviceplan.servicename


# If the service is found in the list of services do something
if($results -match $Lserivce)



write-host $user -ForegroundColor green

#export the name to the CSV file
$user | Export-Csv -Path "C:\users\licencesexport1.csv" -Append -force




This site https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-service-plan-refe... seems to suggest the service should just be called Power BI Pro but that returned an empty CSV which took nearly an hour to run. I can see there is a GUID included in that page too but none of the cmdlets I've tried have seemed to allow me to search for that.


Any help greatly appreciated before the laptop goes out the window...!

1 Reply

To list all users who have a given service plan enabled, use this:


Get-MsolUser | ? {$_.Licenses.ServiceStatus | ? {$_.ServicePlan.ServiceName -eq "BI_AZURE_P2" -and $_.ProvisioningStatus -eq "Success"}}


If you want to further narrow down by license type, just add another clause:


Get-MsolUser | ? {($_.Licenses.AccountSkuId -eq "tenant:ENTERPRISEPREMIUM") -and ($_.Licenses.ServiceStatus | ? {$_.ServicePlan.ServiceName -eq "BI_AZURE_P2" -and $_.ProvisioningStatus -eq "Success"})}