Skip to content

Commit 7566fcf

Browse files
authored
Merge pull request #579 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 6148ca0 + 2290774 commit 7566fcf

File tree

2 files changed

+61
-5
lines changed

2 files changed

+61
-5
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
4+
name: Build and deploy Powershell project to Azure Function App - cipprzztk
5+
6+
on:
7+
push:
8+
branches:
9+
- dev
10+
workflow_dispatch:
11+
12+
env:
13+
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: 'Checkout GitHub Action'
21+
uses: actions/checkout@v4
22+
23+
- name: 'Run Azure Functions Action'
24+
uses: Azure/functions-action@v1
25+
id: fa
26+
with:
27+
app-name: 'cipprzztk'
28+
slot-name: 'Production'
29+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
30+
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_6BF73382D72849FDAC19ED21F09B28B8 }}
31+
sku: 'flexconsumption'
32+

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,45 @@ function Get-CIPPAlertExpiringLicenses {
1111
$TenantFilter
1212
)
1313
try {
14+
# Parse input parameters - default to 30 days if not specified
15+
# Support both old format (direct value) and new format (object with properties)
16+
if ($InputValue -is [hashtable] -or $InputValue -is [PSCustomObject]) {
17+
$DaysThreshold = if ($InputValue.ExpiringLicensesDays) { [int]$InputValue.ExpiringLicensesDays } else { 30 }
18+
$UnassignedOnly = if ($null -ne $InputValue.ExpiringLicensesUnassignedOnly) { [bool]$InputValue.ExpiringLicensesUnassignedOnly } else { $false }
19+
} else {
20+
# Backward compatibility: if InputValue is a simple value, treat it as days threshold
21+
$DaysThreshold = if ($InputValue) { [int]$InputValue } else { 30 }
22+
$UnassignedOnly = $false
23+
}
24+
1425
$AlertData = Get-CIPPLicenseOverview -TenantFilter $TenantFilter | ForEach-Object {
1526
$TermData = $_.TermInfo | ConvertFrom-Json
27+
$UnassignedCount = [int]$_.CountAvailable
28+
29+
# If unassigned only filter is enabled, skip licenses with no unassigned units
30+
if ($UnassignedOnly -and $UnassignedCount -le 0) {
31+
return
32+
}
33+
1634
foreach ($Term in $TermData) {
17-
if ($Term.DaysUntilRenew -lt 30 -and $Term.DaysUntilRenew -gt 0) {
18-
Write-Host "$($_.License) will expire in $($Term.DaysUntilRenew) days. The estimated term is $($Term.Term)"
35+
if ($Term.DaysUntilRenew -lt $DaysThreshold -and $Term.DaysUntilRenew -gt 0) {
36+
$Message = if ($UnassignedOnly) {
37+
"$($_.License) has $UnassignedCount unassigned license(s) expiring in $($Term.DaysUntilRenew) days. The estimated term is $($Term.Term)"
38+
} else {
39+
"$($_.License) will expire in $($Term.DaysUntilRenew) days. The estimated term is $($Term.Term)"
40+
}
41+
42+
Write-Host $Message
1943
[PSCustomObject]@{
20-
Message = "$($_.License) will expire in $($Term.DaysUntilRenew) days. The estimated term is $($Term.Term)"
44+
Message = $Message
2145
License = $_.License
2246
SkuId = $_.skuId
2347
DaysUntilRenew = $Term.DaysUntilRenew
2448
Term = $Term.Term
2549
Status = $Term.Status
2650
TotalLicenses = $Term.TotalLicenses
2751
CountUsed = $_.CountUsed
52+
CountAvailable = $UnassignedCount
2853
NextLifecycle = $Term.NextLifecycle
2954
Tenant = $_.Tenant
3055
}
@@ -35,5 +60,4 @@ function Get-CIPPAlertExpiringLicenses {
3560

3661
} catch {
3762
}
38-
}
39-
63+
}

0 commit comments

Comments
 (0)