44#>
55
66# ############################# Static variables ########################
7- import-module ./ modules/ EntraTokenAid.psm1 - force
87
98$global :GLOBALMainTableDetailsHEAD = @'
109<div id="mainTableContainer">
@@ -3772,8 +3771,9 @@ function start-InitTasks {
37723771
37733772 $Global :GlobalAuditSummary = @ {
37743773 Time = @ { Start = Get-Date - Format " yyyyMMdd HH:mm" ; End = " " }
3775- Tenant = @ { Name = " " ; Id = " " }
3774+ Tenant = @ { Name = " " ; Id = " " }
37763775 EntraFalcon = @ { Version = " $EntraFalconVersion " ; Source = " https://github.com/CompassSecurity/EntraFalcon" }
3776+ TenantLicense = @ { Name = " " ; Level = 0 }
37773777 Subscriptions = @ { Count = 0 }
37783778 UserAgent = @ { Name = $UserAgent }
37793779 Users = @ { Count = 0 ; Guests = 0 ; Inactive = 0 ; Enabled = 0 ; OnPrem = 0 ; MfaCapable = 0 ; SignInActivity = @ { ' 0-1 month' = 0 ; ' 1-2 months' = 0 ; ' 2-3 months' = 0 ; ' 4-5 months' = 0 ; ' 5-6 months' = 0 ; ' 6+ months' = 0 ; ' Never' = 0 }}
@@ -3790,6 +3790,81 @@ function start-InitTasks {
37903790 }
37913791}
37923792
3793+
3794+ # Function to get the applied Entra teant license
3795+ function Get-EffectiveEntraLicense {
3796+ [CmdletBinding ()]
3797+
3798+ $planPriority = @ (
3799+ @ { Plan = ' AAD_PREMIUM_P2' ; Name = ' Microsoft Entra ID P2' ; Int = 4 }
3800+ @ { Plan = ' AAD_PREMIUM' ; Name = ' Microsoft Entra ID P1' ; Int = 3 }
3801+ @ { Plan = ' AAD_BASIC' ; Name = ' Microsoft Entra ID Basic' ; Int = 2 }
3802+ @ { Plan = ' AAD_FREE' ; Name = ' Microsoft Entra ID Free' ; Int = 1 }
3803+ )
3804+
3805+ $QueryParameters = @ {
3806+ ' $select' = " capabilityStatus,servicePlans"
3807+ }
3808+ try {
3809+ $response = Send-GraphRequest - AccessToken $GLOBALMsGraphAccessToken.access_token - Method GET - Uri ' /subscribedSkus' - QueryParameters $QueryParameters - BetaAPI - UserAgent $ ($GlobalAuditSummary.UserAgent.Name ) - ErrorAction Stop
3810+ } catch {
3811+ Write-Log - Level Debug - Message " Can't get Entra Tenant license. Request to /subscribedSkus failed"
3812+ return [pscustomobject ]@ {
3813+ EntraIDLicencesString = ' Unknown'
3814+ EntraIDLicencesInt = 0
3815+ }
3816+ }
3817+ $skus =
3818+ if ($null -eq $response ) { @ () }
3819+ elseif ($response -is [System.Collections.IEnumerable ] -and -not ($response -is [string ])) { @ ($response ) }
3820+ elseif ($response.PSObject.Properties.Name -contains ' value' ) { @ ($response.value ) }
3821+ else { @ ($response ) }
3822+
3823+ # Entra Free does not have any SKUs
3824+ if ($skus.Count -eq 0 ) {
3825+ return [pscustomobject ]@ {
3826+ EntraIDLicencesString = ' Microsoft Entra ID Free'
3827+ EntraIDLicencesInt = 1
3828+ }
3829+ }
3830+
3831+ $observedPlans = New-Object System.Collections.Generic.HashSet[string ]
3832+
3833+ foreach ($sku in $skus ) {
3834+ if ($null -eq $sku ) { continue }
3835+
3836+ $capabilityStatus = $sku.capabilityStatus
3837+ if ($capabilityStatus -ne ' Enabled' -and $capabilityStatus -ne ' Warning' ) { continue }
3838+
3839+ foreach ($plan in @ ($sku.servicePlans )) {
3840+ if ($null -eq $plan ) { continue }
3841+
3842+ if ($plan.provisioningStatus -ne ' Success' ) { continue }
3843+
3844+ $servicePlanName = [string ]$plan.servicePlanName
3845+ [void ]$observedPlans.Add ($servicePlanName )
3846+ }
3847+ }
3848+
3849+ foreach ($item in $planPriority ) {
3850+ if ($observedPlans.Contains ($item.Plan )) {
3851+ Write-Log - Level Verbose - Message " Entra Tenant license: $ ( $item.Name ) "
3852+ return [pscustomobject ]@ {
3853+ EntraIDLicencesString = $item.Name
3854+ EntraIDLicencesInt = $item.Int
3855+ }
3856+ }
3857+ }
3858+
3859+ Write-Log - Level Verbose - Message " Entra Tenant license: Unknown"
3860+ return [pscustomobject ]@ {
3861+ EntraIDLicencesString = ' Unknown'
3862+ EntraIDLicencesInt = 0
3863+ }
3864+ }
3865+
3866+
3867+
37933868# Function to help built the TXT report (avoiding using slow stuff like format-table)
37943869function Format-ReportSection {
37953870 param (
@@ -4328,4 +4403,4 @@ function Show-EntraFalconBanner {
43284403 Write-Host " "
43294404}
43304405
4331- Export-ModuleMember - Function Show-EntraFalconBanner , AuthenticationMSGraph, Get-Devices , Get-UsersBasic , start-CleanUp , Format-ReportSection , Get-OrgInfo , Get-LogLevel , Write-Log , Invoke-MsGraphRefreshPIM , Write-LogVerbose , Invoke-AzureRoleProcessing , Get-RegisterAuthMethodsUsers , Invoke-EntraRoleProcessing , Get-EntraPIMRoleAssignments , AuthCheckMSGraph, RefreshAuthenticationMsGraph, Get-PimforGroupsAssignments , Invoke-CheckTokenExpiration , Invoke-MsGraphAuthPIM , EnsureAuthMsGraph, Get-AzureRoleDetails , Get-AdministrativeUnitsWithMembers , Get-ConditionalAccessPolicies , Get-EntraRoleAssignments , Get-APIPermissionCategory , Get-ObjectInfo , EnsureAuthAzurePsNative, checkSubscriptionNative, Get-AllAzureIAMAssignmentsNative , Get-PIMForGroupsAssignmentsDetails , Show-EnumerationSummary , start-InitTasks
4406+ Export-ModuleMember - Function Show-EntraFalconBanner , AuthenticationMSGraph, Get-EffectiveEntraLicense , Get- Devices, Get-UsersBasic , start-CleanUp , Format-ReportSection , Get-OrgInfo , Get-LogLevel , Write-Log , Invoke-MsGraphRefreshPIM , Write-LogVerbose , Invoke-AzureRoleProcessing , Get-RegisterAuthMethodsUsers , Invoke-EntraRoleProcessing , Get-EntraPIMRoleAssignments , AuthCheckMSGraph, RefreshAuthenticationMsGraph, Get-PimforGroupsAssignments , Invoke-CheckTokenExpiration , Invoke-MsGraphAuthPIM , EnsureAuthMsGraph, Get-AzureRoleDetails , Get-AdministrativeUnitsWithMembers , Get-ConditionalAccessPolicies , Get-EntraRoleAssignments , Get-APIPermissionCategory , Get-ObjectInfo , EnsureAuthAzurePsNative, checkSubscriptionNative, Get-AllAzureIAMAssignmentsNative , Get-PIMForGroupsAssignmentsDetails , Show-EnumerationSummary , start-InitTasks
0 commit comments