Skip to content

Commit 95d48d1

Browse files
committed
Fix for desktop activations copilot ready test
1 parent 5561a5b commit 95d48d1

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

Modules/CIPPTests/Public/Tests/CopilotReadiness/Identity/Invoke-CippTestCopilotReady003.ps1

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,30 @@ function Invoke-CippTestCopilotReady003 {
4646

4747
# For each licensed user, check if they have a desktop activation in the activation report.
4848
# Users absent from the report entirely are counted as unactivated.
49+
# The Graph API returns activation counts nested inside userActivationCounts[] per product type,
50+
# so we sum windows/mac across all product types to get the total desktop activation count.
4951
$NoDesktopUsers = [System.Collections.Generic.List[object]]::new()
5052
$DesktopCount = 0
5153
foreach ($User in $LicensedUsers) {
5254
$Activation = $ActivationLookup[$User.userPrincipalName.ToLower()]
53-
if ($Activation -and (([int]($Activation.windows ?? 0) + [int]($Activation.mac ?? 0)) -gt 0)) {
55+
$TotalWindows = 0
56+
$TotalMac = 0
57+
$TotalAndroid = 0
58+
$TotalIos = 0
59+
if ($Activation.userActivationCounts) {
60+
$TotalWindows = ($Activation.userActivationCounts | Measure-Object -Property windows -Sum).Sum
61+
$TotalMac = ($Activation.userActivationCounts | Measure-Object -Property mac -Sum).Sum
62+
$TotalAndroid = ($Activation.userActivationCounts | Measure-Object -Property android -Sum).Sum
63+
$TotalIos = ($Activation.userActivationCounts | Measure-Object -Property ios -Sum).Sum
64+
}
65+
if ($Activation -and (($TotalWindows + $TotalMac) -gt 0)) {
5466
$DesktopCount++
5567
} else {
5668
$NoDesktopUsers.Add([pscustomobject]@{
5769
displayName = $User.displayName
5870
userPrincipalName = $User.userPrincipalName
59-
web = if ($Activation) { $Activation.web } else { 0 }
60-
android = if ($Activation) { $Activation.android } else { 0 }
61-
ios = if ($Activation) { $Activation.ios } else { 0 }
71+
android = if ($Activation) { $TotalAndroid } else { 0 }
72+
ios = if ($Activation) { $TotalIos } else { 0 }
6273
neverActivated = ($null -eq $Activation)
6374
})
6475
}
@@ -83,7 +94,6 @@ function Invoke-CippTestCopilotReady003 {
8394
$PlatformStr = ' (never activated)'
8495
} else {
8596
$Platforms = @()
86-
if ([int]($User.web ?? 0) -gt 0) { $Platforms += 'Web' }
8797
if ([int]($User.android ?? 0) -gt 0 -or [int]($User.ios ?? 0) -gt 0) { $Platforms += 'Mobile' }
8898
$PlatformStr = if ($Platforms) { " ($(($Platforms -join ', ')) only)" } else { ' (no activations)' }
8999
}
@@ -93,7 +103,7 @@ function Invoke-CippTestCopilotReady003 {
93103
$NeverActivated = @($NoDesktopUsers | Where-Object { $_.neverActivated }).Count
94104
$Result += "**$($NoDesktopUsers.Count) users** have no desktop M365 Apps activation"
95105
if ($NeverActivated -gt 0) { $Result += " ($NeverActivated have never activated on any platform)" }
96-
$Result += '.`n'
106+
$Result += ".`n"
97107
}
98108
}
99109

0 commit comments

Comments
 (0)