0
votes

I'm using the following article View account license and service details with Office 365 PowerShell to try to obtain a report of all users in our tenant where the product license Office 365 Enterprise E3 is assigned but with only the the service Exchange Online (Plan 2) enabled.

The article suggests this can be done with a command similar to the following:

Get-MsolUser | 
Where-Object {
   $_.isLicensed -eq $true 
   -and $_.Licenses[0].ServiceStatus[16].ProvisioningStatus -eq "Enabled"
}

In my case [16] being the 17th service in the list for Office 365 Enterprise E3.

There are additional lines before to set the criteria for the rest of the services as "disabled" but hopefully you get the idea however, the article also states that the index number reflects the order that the product license and service plan appears when running either of the below script blocks:

Licenses:

Get-MsolUser -UserPrincipalName [email protected]  | Format-List DisplayName,Licenses

Services:

Get-MsolUser -UserPrincipalName [email protected]).Licenses.ServiceStatus

The issue with the above is that many users have different combinations of plans enabled so for some, a license index of [0] would refer to a different service plan. e.g. user1 has Visio Online Plan 2 and Office 365 Enterprise E3 product licenses assigned but user2 only Office 365 Enterprise E3. Index [0] in this instance would be different making the initial script block useless in finding all users with a specific service enabled regardless of combination of product licenses assigned.

Am I missing something here?

2

2 Answers

0
votes

Not really sure how I missed it on my searches but the following will provide the information I require without the need to script it: Office 365 License Reporting and Management Tool -Assign Remove Licenses in Bulk

0
votes

I know it's a bit old but today I've had exactly same problem and managed to write a quick function which just does what you asked for.

[cmdletbinding()]

param (
          #Provide service name e.g. SWAY
          [Parameter(Mandatory)]
          [string]$Service,

          #Specifies if to search for enabled or disabled service. Success = enabled.
          [Parameter(Mandatory)]
          [ValidateSet("Success","Disabled")]
          [string]$Status
     )


     foreach ($User in  ($Users = Get-MsolUser -All)  ) {

          $ServiceStatus = $user.licenses.ServiceStatus

          $ProvisionName = $ServiceStatus | Where {$_.ServicePlan.ServiceName -eq "$Service" }

          $Data = [PSCustomObject]@{
               "USER" = $User.UserPrincipalName
               "Software" = $ProvisionName.ServicePlan.ServiceName
               "Status" = $ProvisionName.ProvisioningStatus
          }

          $Data | Where {$_.Status -eq "$Status" }     

          }