Skip to content

Commit

Permalink
Update test-licensetype to check for government (g5 / g3) license types.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnybottles committed Jan 18, 2025
1 parent 8a5c4a3 commit 09e640d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Hawk/internal/functions/Test-LicenseType.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
function Test-LicenseType {
<#
.SYNOPSIS
Identifies the Microsoft 365 license type (E5, E3, or other) for the current tenant and returns both the license type and corresponding retention period.
Identifies the Microsoft 365 license type (E5/G5, E3/G3, or other) for the current tenant and returns both the license type and corresponding retention period.
.DESCRIPTION
This function retrieves the list of subscribed SKUs for the tenant using the Microsoft Graph API. It determines the license type based on the `SkuPartNumber` and returns both the license type and appropriate audit log retention period:
- E5 licenses (including equivalents like Developer Pack E5): 365 days retention
- E3 licenses (including equivalents like Developer Pack E3): 180 days retention
- E5/G5 licenses (including equivalents): 365 days retention
- E3/G3 licenses (including equivalents): 180 days retention
- Other/Unknown licenses: 90 days retention
.EXAMPLE
PS> Test-HawkLicenseType
PS> Test-LicenseType
LicenseType RetentionPeriod
----------- ---------------
Expand All @@ -19,16 +19,16 @@ function Test-LicenseType {
Returns E5 license type and 365 days retention period.
.EXAMPLE
PS> Test-HawkLicenseType
PS> Test-LicenseType
LicenseType RetentionPeriod
----------- ---------------
E3 180
G3 180
Returns E3 license type and 180 days retention period.
Returns G3 license type and 180 days retention period.
.EXAMPLE
PS> Test-HawkLicenseType
PS> Test-LicenseType
LicenseType RetentionPeriod
----------- ---------------
Expand All @@ -38,7 +38,7 @@ function Test-LicenseType {
.NOTES
Author: Jonathan Butler
Last Updated: January 9, 2025
Last Updated: January 18, 2025
.LINK
https://learn.microsoft.com/en-us/powershell/microsoftgraph
Expand All @@ -57,16 +57,16 @@ function Test-LicenseType {
RetentionPeriod = 90
}

# Check for E5 or equivalent license
if ($subscriptions.SkuPartNumber -match 'ENTERPRISEPREMIUM|SPE_E5|DEVELOPERPACK_E5|M365_E5') {
$licenseInfo.LicenseType = 'E5'
# Check for E5/G5 or equivalent license
if ($subscriptions.SkuPartNumber -match 'ENTERPRISEPREMIUM|SPE_E5|DEVELOPERPACK_E5|M365_E5|SPE_G5|ENTERPRISEPREMIUM_GOV|M365_G5|MICROSOFT365_G5') {
$licenseInfo.LicenseType = if ($subscriptions.SkuPartNumber -match '_G5|_GOV') { 'G5' } else { 'E5' }
$licenseInfo.RetentionPeriod = 365
return $licenseInfo
}

# Check for E3 or equivalent license
if ($subscriptions.SkuPartNumber -match 'ENTERPRISEPACK|M365_E3|DEVELOPERPACK_E3') {
$licenseInfo.LicenseType = 'E3'
# Check for E3/G3 or equivalent license
if ($subscriptions.SkuPartNumber -match 'ENTERPRISEPACK|M365_E3|DEVELOPERPACK_E3|SPE_G3|ENTERPRISEPACK_GOV|M365_G3|MICROSOFT365_G3') {
$licenseInfo.LicenseType = if ($subscriptions.SkuPartNumber -match '_G3|_GOV') { 'G3' } else { 'E3' }
$licenseInfo.RetentionPeriod = 180
return $licenseInfo
}
Expand Down

0 comments on commit 09e640d

Please sign in to comment.