Skip to content

Commit 6e9434d

Browse files
authored
Merge pull request KelvinTegelaar#1587 from MWGMorningwood/dev
Add zero count check to Get-CIPPAlertNoCAConfig
2 parents 2848860 + a2648c2 commit 6e9434d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertNoCAConfig.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ function Get-CIPPAlertNoCAConfig {
1212
)
1313

1414
try {
15-
$CAAvailable = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $TenantFilter -ErrorAction Stop).serviceplans
16-
if ('AAD_PREMIUM' -in $CAAvailable.servicePlanName) {
15+
# Only consider CA available when a SKU that grants it has enabled seats (> 0)
16+
$SubscribedSkus = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/subscribedSkus?`$select=prepaidUnits,servicePlans" -tenantid $TenantFilter -ErrorAction Stop
17+
$CAAvailable = foreach ($sku in $SubscribedSkus) {
18+
if ([int]$sku.prepaidUnits.enabled -gt 0) { $sku.servicePlans }
19+
}
20+
21+
if (('AAD_PREMIUM' -in $CAAvailable.servicePlanName) -or ('AAD_PREMIUM_P2' -in $CAAvailable.servicePlanName)) {
1722
$CAPolicies = (New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies' -tenantid $TenantFilter)
1823
if (!$CAPolicies.id) {
1924
$AlertData = 'Conditional Access is available, but no policies could be found.'

0 commit comments

Comments
 (0)