Skip to content

Commit

Permalink
Fix error when tenant has no licenses
Browse files Browse the repository at this point in the history
Running on a new tenant with no licenses in use Get-MgBetaSubscribedSku will return with a body of [].

$LicenseInfo was not verifying $SubscribedSku had data before creating the variable that will be used in the report, resulting in a JSON primitive error because the JSON is "license_information":  ,
  • Loading branch information
Jeff-Jerousek authored Jun 5, 2024
1 parent 5f94a27 commit 76510d7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ function Export-AADProvider {
$ServicePlans = $SubscribedSku.ServicePlans | Where-Object -Property ProvisioningStatus -eq -Value "Success"

#Obtains license information for tenant and total number of active users
$LicenseInfo = $SubscribedSku | Select-Object -Property Sku*, ConsumedUnits, PrepaidUnits | ConvertTo-Json -Depth 3
if ($null -eq $SubscribedSku)
{$LicenseInfo = "[]"}
else{
$LicenseInfo = $SubscribedSku | Select-Object -Property Sku*, ConsumedUnits, PrepaidUnits | ConvertTo-Json -Depth 3
}

if ($ServicePlans) {
# The RequiredServicePlan variable is used so that PIM Cmdlets are only executed if the tenant has the premium license
Expand Down

0 comments on commit 76510d7

Please sign in to comment.